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

Bug 314595

Summary: Prevent PluginModelManager from being instantiated
Product: [Eclipse Project] PDE Reporter: Curtis Windatt <curtis.windatt.public>
Component: UIAssignee: Ankur Sharma <ankur_sharma>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: ankur_sharma, darin.eclipse
Version: 3.6   
Target Milestone: 3.7 M2   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Patch
none
Additional patch
none
patch none

Description Curtis Windatt CLA 2010-05-26 22:31:14 EDT
Bug 313922 was caused by additional PluginModelManagers being instantiated whenever a feature launch occurred.  Each time a manager is instantiated it registers listeners that affect the java build path.

To prevent bugs like this in the future we should prevent PluginModelManager from being instantiated.  We can add a javadoc comment, make the constructor package visible (PDECore being the only place that should instantiate), and/or make the class a singleton (with getInstance() instead of a public constructor).
Comment 1 Ankur Sharma CLA 2010-06-07 09:08:56 EDT
Created attachment 171259 [details]
Patch
Comment 2 Ankur Sharma CLA 2010-06-30 07:02:13 EDT
Fixed in HEAD
Comment 3 Darin Wright CLA 2010-08-03 13:55:44 EDT
Looking at the code, there is some clean up that we should do here.

The #getInstance() method on PluginModelManager should be synchronized to avoid having 2 instances created from different threads in a race condition. As well, since the singleton is cahced in the PluginModelManager class, PDECore should not keep a reference to the singleton either...(i.e. in fModelManager). It should always delegate to the #getInstance() method.

In fact, none of the singleton objects in PDECore are created synch blocks, and this should be investigated (i.e. fModelManager, fTargetProfileManager, fFeatureModelManager...).
Comment 4 Ankur Sharma CLA 2010-08-13 07:21:45 EDT
Created attachment 176544 [details]
Additional patch

Added synchronized and cleaned up PDECore
Comment 5 Darin Wright CLA 2010-08-13 15:00:41 EDT
Created attachment 176579 [details]
patch

Added synchronization on creation of other singletons in PDE Core.
Comment 6 Darin Wright CLA 2010-08-13 15:06:38 EDT
Applied/Fixed.