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

Bug 327488

Summary: Using ":" in URIs can cause StringIndexOutOfBoundsException
Product: [Modeling] TMF Reporter: Moritz Eysholdt <moritz.eysholdt>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: sebastian.zarnekow, sven.efftinge
Version: 1.0.1Flags: sven.efftinge: kepler+
Target Milestone: M4   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Moritz Eysholdt CLA 2010-10-11 19:24:20 EDT
To reproduce, execute:
URI.createURI("org/eclipse/xtext/Xtext.xtext#XtextFragmentProvider::org.eclipse.xtext.Xtext", true)

Cause: URI.encodeURI(String, boolean, int) takes the first colon as separator between scheme and authority/segments. This works fine with absolute URIs (the one that have a scheme), but fails for relative URIs.

Proposed change: Don't use colons (":") in org.eclipse.xtext.xtext.XtextFragmentProvider.PREFIX as separator.


I ran into this when trying to persist an XMI file containing relative URIs. Trace:
Thread [Worker-9] (Suspended (exception StringIndexOutOfBoundsException))	
	String.substring(int, int) line: 1768	
	URI.encodeURI(String, boolean, int) line: 2902	
	URI.createURI(String, boolean) line: 568	
	BuilderStateFactoryImpl.createEURIFromString(EDataType, String) line: 157	
	BuilderStateFactoryImpl.createFromString(EDataType, String) line: 86	
	XMIHelperImpl(XMLHelperImpl).createFromString(EFactory, EDataType, String) line: 1621	
	XMIHelperImpl(XMLHelperImpl).setValue(EObject, EStructuralFeature, Object, int) line: 1162	
	SAXXMIHandler(XMLHandler).setFeatureValue(EObject, EStructuralFeature, Object, int) line: 2657	
	SAXXMIHandler(XMLHandler).setAttribValue(EObject, String, String) line: 2716	
	SAXXMIHandler.handleObjectAttribs(EObject) line: 85	
	SAXXMIHandler(XMLHandler).createObjectFromFactory(EFactory, String) line: 2192	
	SAXXMIHandler(XMLHandler).createObjectFromFeatureType(EObject, EStructuralFeature) line: 2158	
	SAXXMIHandler(XMLHandler).createObject(EObject, EStructuralFeature) line: 2034	
	SAXXMIHandler(XMIHandler).createObject(EObject, EStructuralFeature) line: 134	
	SAXXMIHandler(XMLHandler).handleFeature(String, String) line: 1839	
	SAXXMIHandler(XMLHandler).processElement(String, String, String) line: 1023	
	SAXXMIHandler(XMIHandler).processElement(String, String, String) line: 87	
	SAXXMIHandler(XMLHandler).startElement(String, String, String) line: 1001	
	SAXXMIHandler(XMLHandler).startElement(String, String, String, Attributes) line: 712	
	SAXXMIHandler(XMIHandler).startElement(String, String, String, Attributes) line: 169	
	SAXParser(AbstractSAXParser).startElement(QName, XMLAttributes, Augmentations) line: 533	
	SAXParser(AbstractXMLDocumentParser).emptyElement(QName, XMLAttributes, Augmentations) line: 220	
	XMLDocumentScannerImpl(XMLDocumentFragmentScannerImpl).scanStartElement() line: 872	
	XMLDocumentScannerImpl$ContentDispatcher(XMLDocumentFragmentScannerImpl$FragmentContentDispatcher).dispatch(boolean) line: 1693	
	XMLDocumentScannerImpl(XMLDocumentFragmentScannerImpl).scanDocument(boolean) line: 368	
	JAXPConfiguration(XML11Configuration).parse(boolean) line: 834	
	JAXPConfiguration(XML11Configuration).parse(XMLInputSource) line: 764	
	SAXParser(XMLParser).parse(XMLInputSource) line: 148	
	SAXParser(AbstractSAXParser).parse(InputSource) line: 1242	
	SAXParserImpl(SAXParser).parse(InputSource, DefaultHandler) line: 375	
	XMILoadImpl(XMLLoadImpl).load(XMLResource, InputStream, Map<?,?>) line: 181	
	XMIResourceImpl(XMLResourceImpl).doLoad(InputStream, Map<?,?>) line: 180	
	XMIResourceImpl(ResourceImpl).load(InputStream, Map<?,?>) line: 1494	
	XMIResourceImpl(ResourceImpl).load(Map<?,?>) line: 1282
Comment 1 Sebastian Zarnekow CLA 2011-05-04 06:11:34 EDT
Preliminary scheduled for 2.0RC1
Comment 2 Sven Efftinge CLA 2011-05-04 09:59:07 EDT
postponed to SR1
Comment 3 Sven Efftinge CLA 2011-09-26 09:13:29 EDT
not 2.1
Comment 4 Sven Efftinge CLA 2012-11-20 10:57:46 EST
pushed to master
Comment 5 Eclipse Webmaster CLA 2017-10-31 10:49:01 EDT
Requested via bug 522520.

-M.
Comment 6 Eclipse Webmaster CLA 2017-10-31 11:00:04 EDT
Requested via bug 522520.

-M.