Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 325664 - [localdiscovery] StringIndexOutOfBoundsException when Remote-Service path is at root of bundle
Summary: [localdiscovery] StringIndexOutOfBoundsException when Remote-Service path is ...
Status: RESOLVED FIXED
Alias: None
Product: ECF
Classification: RT
Component: ecf.remoteservices (show other bugs)
Version: 3.3.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.4.0   Edit
Assignee: Scott Lewis CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-17 18:55 EDT by Neil Bartlett CLA
Modified: 2010-09-17 21:48 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Neil Bartlett CLA 2010-09-17 18:55:38 EDT
An exception is thrown if the path indicated in Remote-Service does not include at least one '/' character (i.e. is at the root of the bundle). For example:

   Remote-Service: my-service.xml

will throw the following exception:

Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(String.java:1937)
	at org.eclipse.ecf.osgi.services.discovery.local.BundleTrackerImpl.handleRemoteService(BundleTrackerImpl.java:180)
	at org.eclipse.ecf.osgi.services.discovery.local.BundleTrackerImpl.getRemoteServiceInformationFilesFromBundle(BundleTrackerImpl.java:157)
	at org.eclipse.ecf.osgi.services.discovery.local.BundleTrackerImpl.checkBundleAndPublishServices(BundleTrackerImpl.java:88)
	at org.eclipse.ecf.osgi.services.discovery.local.BundleTrackerImpl.addingBundle(BundleTrackerImpl.java:78)
Comment 1 Scott Lewis CLA 2010-09-17 21:48:16 EDT
Fix released to HEAD.

Fix was to replace this code:

		String path = token.substring(0, token.lastIndexOf("/"));

with this

		int lastSlash = token.lastIndexOf("/");
		String path = (lastSlash <= 0)?"/":token.substring(0,lastSlash);

This assures that if the there is no slash at all, or the slash is in the first position, the intention is to assume the file is at the bundle root ("/")

Resolving as fixed.  Thanks Neil for the report.