Bug 395632 - Tracing UI bundle declarative service causes the workspace prompt to not display
Summary: Tracing UI bundle declarative service causes the workspace prompt to not display
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2.1   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: 4.3 M4   Edit
Assignee: Curtis Windatt CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on: 369916
Blocks: 395767
  Show dependency tree
 
Reported: 2012-12-03 11:59 EST by Troy Bishop CLA
Modified: 2012-12-05 03:51 EST (History)
3 users (show)

See Also:


Attachments
Potential patch using the StartupMonitor suggestion (5.45 KB, patch)
2012-12-04 15:39 EST, Troy Bishop CLA
curtis.windatt.public: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Troy Bishop CLA 2012-12-03 11:59:11 EST
The declarative service for calling the tracing initializer class in the org.eclipse.ui.trace bundle can cause the workspace prompt to not display.  If this service is run before the workspace is initialized then its activator class will attempt to access the instance scoped preferences (i.e. workspace preferences):

@Override
public void start(final BundleContext context) throws Exception {
	...
	if (DebugOptionsHandler.isTracingEnabled()) {
		...
	} else if (PreferenceHandler.isTracingEnabled()) { <-- accesses prefs in workspace
		...
	}
}

As a result of doing this action before the workspace is initialized then the workspace location is set to be the location specified via the osgi.instance.area.default configuration property and the prompt is not displayed to change it.

I'm marking this as 'major' since our Eclipse-based product causes this situation to occur and the workspace prompt never displays.
Comment 1 Curtis Windatt CLA 2012-12-04 13:05:47 EST
If we can't find a better solution, we should be able to implement IStartup to load preference information after a workspace is selected.
Comment 2 Troy Bishop CLA 2012-12-04 13:10:56 EST
I would also like to request that a solution needs to be implemented in the 4.2.2 release.
Comment 3 Curtis Windatt CLA 2012-12-04 14:25:14 EST
We can fall back to using Eclipse early start (IStartup), but Paul has suggested two possible alternatives.

1)
Keep the DS in place
When the bundle is activated, check that org.eclipse.core.runtime.Platform.getInstanceLocation().isSet() returns true
If it is, access the preferences
If not, register a StartupMonitor service which will be called during splash takedown (this is earlier than IStartup).  When we get the call back, preferences will be available.

2) 
Have the DS depend on the IWorkbench service

Implementing 2 is easier, but tracing would not be enabled until much later during startup.
Comment 4 Troy Bishop CLA 2012-12-04 15:39:46 EST
Created attachment 224277 [details]
Potential patch using the StartupMonitor suggestion
Comment 5 Curtis Windatt CLA 2012-12-04 17:42:48 EST
Fixed in master:
http://git.eclipse.org/c/pde/eclipse.pde.ui.git/commit/?id=8d46594bf85c01f5e7f84c9f4485c4659cbf2fc5

The patch worked great, thanks Troy.  Note for testing that you can get the workspace prompt to open when self hosting by deleting the workspace location in your launch configuration.

I separated out the non-nls tag change into a separate commit to make it easier to cherry pick when backporting.  I also changed the startup monitor to store its own service reference and unregister itself after initializing the preferences.

I will clone this bug for 3.8.2/4.2.2.