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

Bug 361242

Summary: [Builder] NPE in ClusteringBuilder
Product: [Modeling] TMF Reporter: Sven Efftinge <sven.efftinge>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 Flags: sven.efftinge: indigo+
Version: 2.1.0   
Target Milestone: SR2   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Sven Efftinge CLA 2011-10-18 07:35:19 EDT
In the clustering builder the variable queue and loadOperation both hold a copy of the list of URIs.

While an entry is automatically removed from loadOperations when next is called.

 Resource loadResult = loadOperation.next();
 changedURI = loadResult.getURI();

It is manually removed from the queue later on.

 queue.remove(changedURI);

Unfortunately the URI is retrieved from Resource and might be different (normalization). So the original URI is not removed from the queue and the two lists run out-of-sync.

Result:

java.lang.NullPointerException
	at org.eclipse.xtext.resource.ClasspathUriUtil.isClasspathUri(ClasspathUriUtil.java:25)
	at org.eclipse.xtext.resource.XtextResourceSet$1.normalize(XtextResourceSet.java:52)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:361)
	at org.eclipse.xtext.builder.resourceloader.SerialResourceLoader$1.next(SerialResourceLoader.java:45)
	at org.eclipse.xtext.builder.resourceloader.AbstractResourceLoader$CheckedLoadOperation.next(AbstractResourceLoader.java:74)
	at org.eclipse.xtext.builder.clustering.ClusteringBuilderState.doUpdate(ClusteringBuilderState.java:195)
	at org.eclipse.xtext.builder.builderState.AbstractBuilderState.update(AbstractBuilderState.java:107)
	at org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBuilder.java:158)
	at org.eclipse.xtext.builder.impl.XtextBuilder.fullBuild(XtextBuilder.java:183)
	at org.eclipse.xtext.builder.impl.XtextBuilder.build(XtextBuilder.java:85)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:728)

I suggest to change the protocol of 
org.eclipse.xtext.builder.resourceloader.IResourceLoader.LoadOperation.next()
to return a type 

class LoadResult {
   Resource resource;
   /**
    * the URI, which was originally used for the load operation
    */
   URI uri;
}

such that the original URI is accessible.
Comment 1 Sven Efftinge CLA 2011-10-18 11:04:39 EDT
pushed to master
Comment 2 Karsten Thoms CLA 2017-09-19 17:43:50 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 3 Karsten Thoms CLA 2017-09-19 17:54:55 EDT
Closing all bugs that were set to RESOLVED before Neon.0