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

Bug 243893

Summary: [prefs] Race condition in EclipsePreferences
Product: [Eclipse Project] Equinox Reporter: Min Idzelis <min123>
Component: ComponentsAssignee: equinox.components-inbox <equinox.components-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3    
Version: 3.4   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
JavaCore with stacks, etc none

Description Min Idzelis CLA 2008-08-12 11:09:57 EDT
Created attachment 109791 [details]
JavaCore with stacks, etc

Build ID: Eclipse 3.4Rac

Steps To Reproduce:
If two threads simultaneously access a Project preference for a preference node that hasn't been created yet, a race condition can result. 

If you look at EclipsePreferences's javadoc, it says

" * Implementation notes:
 * 
 *  - For thread safety, we always synchronize on the node object when writing
 * the children or properties fields.  Must ensure we don't synchronize when calling
 * client code such as listeners.
"

However, the lock is not held when the project node doesn't exist. The "create()" method in EclipsePreferences should be made threadsafe.

Additionally, the state of the static field "loadedNodes" is shared and improperly synchronized. 

It should be wrapped with a synchronized set. Additionally, the method removeLoadedNodes() should synchronize on the set while it's iterating it.
Comment 1 DJ Houghton CLA 2008-09-01 11:23:10 EDT
The issue with the loadedNodes is covered by bug 158361 and has been fixed in both the 3.4.x builds and the 3.5 builds.
Comment 2 John Arthorne CLA 2012-04-09 13:12:10 EDT

*** This bug has been marked as a duplicate of bug 376206 ***