Bug 496840 - UiSynchronizer.DEFAULT may be not initialized
Summary: UiSynchronizer.DEFAULT may be not initialized
Status: RESOLVED FIXED
Alias: None
Product: Handly
Classification: Technology
Component: Core (show other bugs)
Version: 0.4   Edit
Hardware: PC Mac OS X
: P3 normal
Target Milestone: 0.6   Edit
Assignee: Vladimir Piskarev CLA
QA Contact: Vladimir Piskarev CLA
URL:
Whiteboard: breakingchange
Keywords: api
Depends on:
Blocks:
 
Reported: 2016-06-27 10:03 EDT by George Suaridze CLA
Modified: 2016-07-07 04:51 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description George Suaridze CLA 2016-06-27 10:03:01 EDT
UiSynchronizer.DEFAULT is initialized in time of "org.eclipse.handly" bundle activation. See org.eclipse.handly.internal.Activator:

    @Override
    public void start(BundleContext context) throws Exception
    {
        super.start(context);
        Bundle b = Platform.getBundle("org.eclipse.ui"); //$NON-NLS-1$
        if (b != null && b.getState() == Bundle.ACTIVE
            && PlatformUI.isWorkbenchRunning())
        {
            UiSynchronizer.DEFAULT = new DisplaySynchronizer(
                PlatformUI.getWorkbench().getDisplay());
        }
    }

There may be situation when org.eclipse.handly is activated before org.eclipse.ui, or workbench not started yet. Therefore UiSynchronizer.DEFAULT stays uninitialized.


Correct initialization of this static field is not an easy task I think, so what if remove this field and create new DisplaySynchronizer each time it is needed?
Comment 1 Vladimir Piskarev CLA 2016-06-27 11:07:37 EDT
Thanks George for pointing it out. The bug has been lurking for quite some time. Your suggestion sounds reasonable, but UiSynchronizer is an API, so it would be a breaking change. I'm setting the target to 0.6 then.
Comment 2 George Suaridze CLA 2016-06-29 04:11:21 EDT
Vladimir, OK. 0.6 is not a problem, I am using workaround that fits my needs now
Comment 3 Eclipse Genie CLA 2016-07-07 03:43:24 EDT
New Gerrit change created: https://git.eclipse.org/r/76814
Comment 5 Vladimir Piskarev CLA 2016-07-07 04:51:08 EDT
Breaking changes in UiSynchronizer:

* public static UiSynchronizer DEFAULT -> public static UiSynchronizer getDefault()

* synchExec(Runnable) may now throw a checked java.util.concurrent.ExecutionException

* getThread(), asyncExec(Runnable), and syncExec(Runnable) may now throw IllegalStateException