Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 347887 - Multithreading issue in InternalPlatform.getContentTypeManager leads to NullpointerException in org.eclipse.emf.ecore.resource.impl.PlatformContentHandlerImpl
Summary: Multithreading issue in InternalPlatform.getContentTypeManager leads to Nullp...
Status: CLOSED DUPLICATE of bug 356306
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Runtime (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows 7
: P3 critical (vote)
Target Milestone: ---   Edit
Assignee: platform-runtime-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-01 04:16 EDT by Andreas Buehler CLA
Modified: 2011-09-21 13:33 EDT (History)
2 users (show)

See Also:


Attachments
Stacktrace of the NullPointerException (1.46 KB, text/plain)
2011-06-01 04:18 EDT, Andreas Buehler CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Buehler CLA 2011-06-01 04:16:24 EDT
Build Identifier: 3.6.0

We use the Eclipse RCP platform in a highly concurrent environment.
Sometimes our application throws a NullPointerException shortly after it's being started - which is not really reproducible in a safe way.

The stacktrace issues a NullPointer in this line: org.eclipse.emf.ecore.resource.impl.PlatformContentHandlerImpl.contentDescription(PlatformContentHandlerImpl.java:92)

After investigating the source code, I came to the conclusion that the only way a NullPointer could happen is that the InternalPlatform.getContentTypeManager returns null.

I believe the lazy initialisation in this method is not threadsafe and therefore this issue occures.

Thread A recognizes the contentTracker as null and instantiates the member.
but between the class instantiation of the Service Tracker and the call to "open()" Thread B recognizes the member variable beeing set and jumps to the end of the method, calling getService() on the "at this point" not opened service tracker. 
The service tracker itself will return null in case it's not yet being opened :-(


Reproducible: Sometimes

Steps to Reproduce:
1. Access Platform.getContentTypeManager simultaneously in multiple threads
2.
3.
Comment 1 Andreas Buehler CLA 2011-06-01 04:18:30 EDT
Created attachment 197064 [details]
Stacktrace of the NullPointerException

The attachments shows the Nullpointer, which is caused by the Platform.getContentTypeManager not being threadsafe
Comment 2 DJ Houghton CLA 2011-09-21 13:33:27 EDT
I believe this is a duplicate of bug 356306.
Please re-open if you are still seeing this behaviour in recent builds.
Thanks.

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