Project: Eclipse_Platform_UI
Bug 202057 [RCP] [Workbench] NullPointerException if workbench.close() is called in preStartup of the WorkbenchAdvisor
Reported: 2007-09-03 05:10:18 | Status: verified fixed

Build ID: I20070621-1340 Steps To Reproduce: 1. Overwrite the preStartup() method in XXXWorkbenchAdvisor with public void preStartup() { getWorkbenchConfigurer().getWorkbench().close(); } 2. Start the application. 3. A NullPointerException occurs. It should be possible to close or restart the application even in the preStartup state without NPE's. More information: Exception in thread "Thread-2" java.lang.NullPointerException: The parent handler service cannot be null at org.eclipse.ui.internal.handlers.SlaveHandlerService.<init>(SlaveHandlerService.java:99) at org.eclipse.ui.internal.WorkbenchWindow.initializeDefaultServices(WorkbenchWindow.java:3825) at org.eclipse.ui.internal.WorkbenchWindow.<init>(WorkbenchWindow.java:360) at org.eclipse.ui.internal.Workbench.newWorkbenchWindow(Workbench.java:1725) at org.eclipse.ui.internal.Workbench.access$14(Workbench.java:1724) at org.eclipse.ui.internal.Workbench$18.runWithException(Workbench.java:1001) at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3212) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2956) at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:797) at org.eclipse.ui.internal.Workbench$25.runWithException(Workbench.java:1342) at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3212) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2956) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2309) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219) at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.examples.rcp.mail.Application.start(Application.java:26) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:153) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:504) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:443) at org.eclipse.equinox.launcher.Main.run(Main.java:1169) at org.eclipse.equinox.launcher.Main.main(Main.java:1144)

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