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

Bug 509273

Summary: NullPointerException after saving target editor
Product: [Eclipse Project] PDE Reporter: RĂ¼diger Herrmann <ruediger.herrmann>
Component: UIAssignee: PDE-UI-Inbox <pde-ui-inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: ruediger.herrmann, Vikas.Chandra
Version: 4.6   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:

Description RĂ¼diger Herrmann CLA 2016-12-15 06:18:54 EST
While saving a target editor, I saw the exception listed below being logged.

It seems as if the P2TargetUtils.fgArtifactKeyRepoFile is accessed by multiple threads. In this case, the entries of fgArtifactKeyRepoFile may change between calling containsKey() and calling get().

Stacktrace:
---
java.lang.NullPointerException
	at org.eclipse.pde.internal.core.target.IUBundleContainer.generateBundle(IUBundleContainer.java:429)
	at org.eclipse.pde.internal.core.target.IUBundleContainer.generateResolvedBundles(IUBundleContainer.java:415)
	at org.eclipse.pde.internal.core.target.IUBundleContainer.cacheBundles(IUBundleContainer.java:306)
	at org.eclipse.pde.internal.core.target.IUBundleContainer.synchronizerChanged(IUBundleContainer.java:332)
	at org.eclipse.pde.internal.core.target.P2TargetUtils.notify(P2TargetUtils.java:807)
	at org.eclipse.pde.internal.core.target.P2TargetUtils.synchronize(P2TargetUtils.java:744)
	at org.eclipse.pde.internal.core.target.TargetDefinition.resolve(TargetDefinition.java:259)
	at org.eclipse.pde.internal.ui.editor.targetdefinition.TargetEditor$TargetChangedListener$1.run(TargetEditor.java:479)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Comment 1 Vikas Chandra CLA 2016-12-15 06:33:26 EST

*** This bug has been marked as a duplicate of bug 507325 ***
Comment 2 Vikas Chandra CLA 2016-12-15 06:39:22 EST
>>fgArtifactKeyRepoFile may change between calling containsKey() and calling get().

yes , one case could be during re-hash by a separate thread.


See bug 507325 for proposed solution. I think a simple NPE check would suffice. Making the hashmap thread-safe is another solution but in this case, simple NPE check would serve our purpose.