Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 329363 - NPE may be thrown due to no workbench windows being found with PDEPlugin.getActivePage()
Summary: NPE may be thrown due to no workbench windows being found with PDEPlugin.getA...
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.7 M4   Edit
Assignee: Curtis Windatt CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-03 11:24 EDT by Remy Suen CLA
Modified: 2010-11-26 16:32 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Remy Suen CLA 2010-11-03 11:24:06 EDT
I20101025-1800

1. Run > Run Configurations...
2. Create a new 'Eclipse Application' launch configuration.
3. Select the 'Plug-ins' tab.
4. Pick 'plug-ins selected below only' from the 'Launch with:' combo control.
5. Deselect everything.
6. Run
7. It will fail. Dismiss the dialog.
8. Position your mouse over the 'X' button of your Eclipse workbench window.
9. Quickly hit Ctrl+F11 to launch, then click your mouse, and immediately hit 'Enter' to confirm the shutdown.
10. You will get the 'Launch Error' dialog.
11. Click the 'Yes, in the Error Log view' button.
12. Of course, it won't show up. Eclipse proceeds to shut itself down.
13. See an NPE in the logs.

org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException)
	at org.eclipse.swt.SWT.error(SWT.java:4091)
	at org.eclipse.swt.SWT.error(SWT.java:4006)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:137)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4059)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3678)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.block(ModalContext.java:173)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:388)
	at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:507)
	at org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog.run(ProgressMonitorJobsDialog.java:275)
	at org.eclipse.ui.internal.ide.application.IDEWorkbenchAdvisor.disconnectFromWorkspace(IDEWorkbenchAdvisor.java:515)
	at org.eclipse.ui.internal.ide.application.IDEWorkbenchAdvisor.postShutdown(IDEWorkbenchAdvisor.java:348)
	at org.eclipse.ui.internal.Workbench.shutdown(Workbench.java:2956)
	at org.eclipse.ui.internal.Workbench.busyClose(Workbench.java:1114)
	at org.eclipse.ui.internal.Workbench.access$15(Workbench.java:1031)
	at org.eclipse.ui.internal.Workbench$25.run(Workbench.java:1275)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.internal.Workbench.close(Workbench.java:1273)
	at org.eclipse.ui.internal.Workbench.close(Workbench.java:1245)
	at org.eclipse.ui.internal.WorkbenchWindow.busyClose(WorkbenchWindow.java:736)
	at org.eclipse.ui.internal.WorkbenchWindow.access$0(WorkbenchWindow.java:715)
	at org.eclipse.ui.internal.WorkbenchWindow$5.run(WorkbenchWindow.java:831)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.internal.WorkbenchWindow.close(WorkbenchWindow.java:829)
	at org.eclipse.jface.window.Window.handleShellCloseEvent(Window.java:741)
	at org.eclipse.jface.window.Window$3.shellClosed(Window.java:687)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:98)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
	at org.eclipse.swt.widgets.Decorations.closeWidget(Decorations.java:308)
	at org.eclipse.swt.widgets.Decorations.WM_CLOSE(Decorations.java:1665)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4167)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1598)
	at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2061)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4891)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2455)
	at org.eclipse.swt.widgets.Shell.callWindowProc(Shell.java:497)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4256)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1598)
	at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2061)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4891)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2455)
	at org.eclipse.swt.widgets.Shell.callWindowProc(Shell.java:497)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4256)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1598)
	at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2061)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4891)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2460)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3673)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:621)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:576)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1409)
Caused by: java.lang.NullPointerException
	at org.eclipse.pde.internal.ui.PDEPlugin.internalGetActivePage(PDEPlugin.java:108)
	at org.eclipse.pde.internal.ui.PDEPlugin.getActivePage(PDEPlugin.java:74)
	at org.eclipse.pde.internal.ui.launcher.LaunchTerminationStatusHandler$2.run(LaunchTerminationStatusHandler.java:63)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
	... 73 more
Comment 1 Curtis Windatt CLA 2010-11-03 11:30:05 EDT
This can also happen when running certain jobs outside the UI thread.
Comment 2 Curtis Windatt CLA 2010-11-26 16:32:48 EST
Fixed in HEAD, see LaunchTerminationStatusHandler and PDEPlugin.

The convenience method from PDEPlugin will now return null instead of throwing an NPE.  As the method is used in a number of places in PDE without a null check there is still the possibility of getting an NPE (though the stack trace will more accurately point to the problem).  I added a null check to the status handler that is causing the specific NPE in this report.