Project: Eclipse_Platform_UI
Bug 321155 [DynamicGUI] UIExtensionTracker calling Display.syncExec() on disposed Display
Reported: 2010-07-28 13:17:41 | Status: verified fixed

Build Identifier: Eclipse SDK 3.6GA I20100608-0911 We have an RCP application that dynamically loads plugins with extensions. The RCP application also dynamically unloads these plugins right before shutting down. We get these exceptions in the <workspace>/.metadata/.log during shutdown: !ENTRY org.eclipse.equinox.registry 4 2 2010-07-28 10:07:45.309 !MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.equinox.registry". !STACK 0 org.eclipse.swt.SWTException: Device is disposed at org.eclipse.swt.SWT.error(SWT.java:4083) at org.eclipse.swt.SWT.error(SWT.java:3998) at org.eclipse.swt.SWT.error(SWT.java:3969) at org.eclipse.swt.widgets.Display.error(Display.java:1204) at org.eclipse.swt.widgets.Display.syncExec(Display.java:4285) at org.eclipse.ui.internal.registry.UIExtensionTracker.applyRemove(UIExtensionTracker.java:42) at org.eclipse.core.runtime.dynamichelpers.ExtensionTracker.notify(ExtensionTracker.java:153) at org.eclipse.core.runtime.dynamichelpers.ExtensionTracker.doRemove(ExtensionTracker.java:179) at org.eclipse.core.runtime.dynamichelpers.ExtensionTracker.registryChanged(ExtensionTracker.java:119) at org.eclipse.core.internal.registry.ExtensionRegistry$2.run(ExtensionRegistry.java:921) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.core.internal.registry.ExtensionRegistry.processChangeEvent(ExtensionRegistry.java:919) at org.eclipse.core.runtime.spi.RegistryStrategy.processChangeEvent(RegistryStrategy.java:260) at org.eclipse.core.internal.registry.osgi.ExtensionEventDispatcherJob.run(ExtensionEventDispatcherJob.java:50) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) !ENTRY org.eclipse.equinox.registry 4 0 2010-07-28 10:07:45.320 !MESSAGE Error notifying registry change listener. !SUBENTRY 1 org.eclipse.equinox.registry 4 0 2010-07-28 10:07:45.320 !MESSAGE Error notifying registry change listener. !STACK 0 org.eclipse.swt.SWTException: Device is disposed at org.eclipse.swt.SWT.error(SWT.java:4083) at org.eclipse.swt.SWT.error(SWT.java:3998) at org.eclipse.swt.SWT.error(SWT.java:3969) at org.eclipse.swt.widgets.Display.error(Display.java:1204) at org.eclipse.swt.widgets.Display.syncExec(Display.java:4285) at org.eclipse.ui.internal.registry.UIExtensionTracker.applyRemove(UIExtensionTracker.java:42) at org.eclipse.core.runtime.dynamichelpers.ExtensionTracker.notify(ExtensionTracker.java:153) at org.eclipse.core.runtime.dynamichelpers.ExtensionTracker.doRemove(ExtensionTracker.java:179) at org.eclipse.core.runtime.dynamichelpers.ExtensionTracker.registryChanged(ExtensionTracker.java:119) at org.eclipse.core.internal.registry.ExtensionRegistry$2.run(ExtensionRegistry.java:921) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.core.internal.registry.ExtensionRegistry.processChangeEvent(ExtensionRegistry.java:919) at org.eclipse.core.runtime.spi.RegistryStrategy.processChangeEvent(RegistryStrategy.java:260) at org.eclipse.core.internal.registry.osgi.ExtensionEventDispatcherJob.run(ExtensionEventDispatcherJob.java:50) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) This happens because there is a race condition between the main UI thread and the ExtensionEventDispatcherJob worker thread during shutdown such that registry change events are being handled after the display has been disposed during shutdown. The registry change events that are fired are due to the dynamic unloading of plugins with extensions. Either UIExtensionTracker should be written to handle the case when the display is disposed (i.e. handle the exception and quietly ignore it) or the extension registry should provide an API that the UI can call during shutdown that waits for these ExtensionEventDispatcherJob jobs to complete (e.g. calls IJobManager.join() on a job family for these jobs). Reproducible: Always

Files changed in fix:
bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/UIExtensionTracker.java