Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 16341

Summary: Dav: Mapping page - StringIndexOutOfBoundsException
Product: [Eclipse Project] Platform Reporter: Kevin McGuire <Kevin_McGuire>
Component: WebDAVAssignee: DJ Houghton <dj.houghton>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Dave_Thomson
Version: 2.0   
Target Milestone: 2.0 F2   
Hardware: Other   
OS: other   
Whiteboard:
Bug Depends on:    
Bug Blocks: 16524    

Description Kevin McGuire CLA 2002-05-18 01:59:28 EDT
1. attempt to connect project to site
   http://www.planetpdf.com/planetpdf/webdavdemo/

2. Expand the site in the Mapping Page.

Bug #1: You will get the following error.
 
Bug #2: No error notification was displayed to the user: it just looked like 
there were no child folders. I believe its that runtime exceptions just fall 
through.


!SESSION ----------------------------------------------------------------------
java.fullversion=J2RE 1.3.0 IBM build cn130-20010502 (JIT disabled)
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_CA
Command-line arguments: -dev bin -data C:\Eclipse_Scratch
!ENTRY org.eclipse.core.runtime 2 1 Sat May 18 01:20:22 EDT 2002
!MESSAGE Problems encountered loading the plug-in registry.
!SUBENTRY 1 org.eclipse.core.runtime 2 1 Sat May 18 01:20:22 EDT 2002
!MESSAGE Plug-in org.eclipse.pde.ui was disabled due to missing or disabled 
prerequisite plug-in org.eclipse.pde.
!ENTRY org.eclipse.core.resources 1 4 Sat May 18 01:32:46 EDT 2002
!MESSAGE Unhandled exception caught in event loop.
!ENTRY org.eclipse.ui 4 0 Sat May 18 01:32:46 EDT 2002
!MESSAGE String index out of range: 43
!STACK java.lang.StringIndexOutOfBoundsException: String index out of range: 43
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:78)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:841)
	at org.eclipse.swt.widgets.Tree.wmNotifyChild(Tree.java:1703)
	at org.eclipse.swt.widgets.Control.WM_NOTIFY(Control.java:3592)
	at org.eclipse.swt.widgets.Composite.WM_NOTIFY(Composite.java:571)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:2700)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:1873)
	at org.eclipse.swt.internal.win32.OS.CallWindowProcA(Native Method)
	at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:1148)
	at org.eclipse.swt.widgets.Tree.callWindowProc(Tree.java:147)
	at org.eclipse.swt.widgets.Tree.WM_LBUTTONDOWN(Tree.java:1332)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:2683)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:1873)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageA(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1215)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1219)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:548)
	at org.eclipse.jface.window.Window.open(Window.java:535)
	at org.eclipse.team.internal.ui.target.TargetProjectAction$1.run
(TargetProjectAction.java:29)
	at org.eclipse.team.internal.ui.actions.TeamAction$1.run
(TeamAction.java:156)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:56)
	at org.eclipse.team.internal.ui.actions.TeamAction.run
(TeamAction.java:153)
	at org.eclipse.team.internal.ui.target.TargetProjectAction.run
(TargetProjectAction.java:22)
	at org.eclipse.ui.internal.PluginAction.runWithEvent
(PluginAction.java:210)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection
(ActionContributionItem.java:407)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent
(ActionContributionItem.java:361)
	at org.eclipse.jface.action.ActionContributionItem.access$0
(ActionContributionItem.java:352)
	at 
org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent
(ActionContributionItem.java:47)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:75)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:637)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1432)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1221)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1062)
	at org.eclipse.ui.internal.Workbench.run(Workbench.java:1045)
	at org.eclipse.core.internal.boot.InternalBootLoader.run
(InternalBootLoader.java:739)
	at org.eclipse.core.boot.BootLoader.run(BootLoader.java:420)
	at EclipseRuntimeLauncher.main(EclipseRuntimeLauncher.java:16)
Comment 1 Kevin McGuire CLA 2002-05-18 02:06:44 EDT
Note that there is *a lot* of content on that site - 455 files/folders.  A good 
big test case!
Comment 2 Kevin McGuire CLA 2002-05-21 00:16:20 EDT
By breaking on StringIndexOutOfBoundsException was able to get the following 
stack.  Trimmed bottom of stack for brevity.

Moving to Core as the exception appears to be caused in
   org.eclipse.webdav.internal.utils.URLDecoder.decode


Thread [main] (Suspended (exception java.lang.StringIndexOutOfBoundsException))
	java.lang.String.charAt(int) line: 508 [local variables unavailable]
	org.eclipse.webdav.internal.utils.URLDecoder.decodeSegment
(java.lang.String) line: 127
	org.eclipse.webdav.internal.utils.URLDecoder.decode(java.lang.String, 
java.lang.String) line: 80
	org.eclipse.webdav.internal.utils.URLDecoder.decode(java.net.URL) line: 
109
	org.eclipse.webdav.internal.utils.URLDecoder.decode(java.lang.String) 
line: 44
	org.eclipse.webdav.dom.ElementEditor.decodeHref(java.lang.String) line: 
420
	org.eclipse.webdav.dom.ResponseBody.getHref() line: 323
	org.eclipse.webdav.client.CollectionHandle
(org.eclipse.webdav.client.AbstractResourceHandle).extractPropStats
(org.eclipse.webdav.dom.MultiStatus) line: 355
	org.eclipse.webdav.client.CollectionHandle
(org.eclipse.webdav.client.AbstractResourceHandle).getProperties
(java.util.Collection, java.lang.String) line: 557
	org.eclipse.webdav.client.CollectionHandle.getMembers() line: 260
	org.eclipse.team.internal.webdav.core.DavRemoteTargetResource.members
(org.eclipse.core.runtime.IProgressMonitor) line: 170
	org.eclipse.team.internal.ui.target.RemoteResourceElement$1.run
(org.eclipse.core.runtime.IProgressMonitor) line: 63
	org.eclipse.team.internal.ui.TeamUIPlugin$2.run() line: 142
	org.eclipse.swt.custom.BusyIndicator.showWhile
(org.eclipse.swt.widgets.Display, java.lang.Runnable) line: 56
	org.eclipse.team.internal.ui.TeamUIPlugin.runWithProgress
(org.eclipse.swt.widgets.Shell, boolean, 
org.eclipse.jface.operation.IRunnableWithProgress) line: 139
	org.eclipse.team.internal.ui.target.RemoteResourceElement.getChildren
(java.lang.Object) line: 60
	org.eclipse.team.internal.ui.target.SiteElement.getChildren
(java.lang.Object) line: 56
	org.eclipse.team.internal.ui.target.SiteLazyContentProvider
Comment 3 Kevin McGuire CLA 2002-05-21 00:17:03 EDT
This time really moving to core :)
Comment 4 Kevin McGuire CLA 2002-05-21 00:46:41 EDT
Following patch is a quick hack which may work (have other problems with test 
case but seems to get further now).  Code should probably be restructured 
though:

Index: URLDecoder.java
===================================================================
RCS 
file: /home/eclipse/org.eclipse.webdav/src/interface/org/eclipse/webdav/internal
/utils/URLDecoder.java,v
retrieving revision 1.5
diff -u -r1.5 URLDecoder.java
--- URLDecoder.java	17 May 2002 17:56:25 -0000	1.5
+++ URLDecoder.java	21 May 2002 04:45:31 -0000
@@ -119,11 +119,12 @@
 	for(int i = 0; i < segment.length(); ++i){
 		char c = segment.charAt(i);
 		if(c == '%'){
-			while(c == '%'){
+			while(c == '%' && i < segment.length()){
 				String hex = segment.substring(i + 1, i + 3);
 				buff.write(Integer.parseInt(hex, 16));
 				i = i + 3;
-				c = segment.charAt(i);
+				if(i < segment.length())
+					c = segment.charAt(i);
 			}
 			try {
 				result.append(buff.toString("UTF8")); //$NON-
NLS-1$
Comment 5 Tim Ellison CLA 2002-05-31 11:23:48 EDT
*** Bug 18397 has been marked as a duplicate of this bug. ***
Comment 6 Tim Ellison CLA 2002-05-31 11:42:21 EDT
Fixed a bug in org.eclipse.webdav.internal.utils.URLDecoder#decodeSegment
(String) in builds > 20020531.

Simple test case is:
org.eclispe.webdav.internal.utils.URLDecoder.decodeSegment("Can you decode this 
%40");

Leaving the bug report open until we verify this was the cause of the reported 
problem.

Comment 7 DJ Houghton CLA 2002-05-31 22:49:26 EDT
Verified fix against URL below.
Closing.