Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 296151

Summary: NullPointerException on closing editors in an Eclipse RCP based application without a status line
Product: [Eclipse Project] Platform Reporter: Bogdan B. <bbarzu>
Component: UIAssignee: Platform-UI-Inbox <Platform-UI-Inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: bbarzu
Version: 3.5   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Bogdan B. CLA 2009-11-25 11:36:57 EST
User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.15) Gecko/2009102100 SUSE/3.0.15-0.1.2 Firefox/3.0.15
Build Identifier: 

I always get a NPE (stack trace follows) when I try to close an editor in an Eclipse RCP based application which has no status line.

I already got a workaround for it:
in my extension of WorkbenchWindowAdvisor.createWindowContents(Shell) I added the following code:

// Workaround: create a hidden status line to prevent NPE on closing an editor at:
// StatusLineManager.getProgressMonitor().setCanceled() --> StatusLineManager.statusLine would be null        getWindowConfigurer().createStatusLineControl(getWindowConfigurer().getWindow().getShell());
getWindowConfigurer().setShowStatusLine(false);

So basically I added an invisible status line, instead of having no status line.
But why should I instantiate it if I don't need it? 
Wouldn't be better if you just check if StatusLineManager.statusLine is not null before calling something on it?

I start the application using an Eclipse 3.5 target:
eclipse.buildId=I20090611-1540
java.version=1.5.0_20
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32

Reproducible: Always

Steps to Reproduce:
1. open an editor in my application (my own extension of FormEditor)
2. modify the contents so it becomes dirty
3. click its close button
4. select No when asked if I want to save the changes
Comment 1 Bogdan B. CLA 2009-11-25 11:40:14 EST
!ENTRY org.eclipse.ui 4 0 2009-11-25 15:25:48.234
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NullPointerException
	at org.eclipse.jface.action.StatusLineManager$1.setCanceled(StatusLineManager.java:188)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:368)
	at org.eclipse.jface.window.ApplicationWindow$1.run(ApplicationWindow.java:759)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWindow.java:756)
	at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2578)
	at org.eclipse.ui.internal.SaveableHelper.runProgressMonitorOperation(SaveableHelper.java:282)
	at org.eclipse.ui.internal.SaveablesList.saveModels(SaveablesList.java:619)
	at org.eclipse.ui.internal.SaveablesList.promptForSaving(SaveablesList.java:583)
	at org.eclipse.ui.internal.SaveablesList.promptForSavingIfNecessary(SaveablesList.java:422)
	at org.eclipse.ui.internal.SaveablesList.preCloseParts(SaveablesList.java:383)
	at org.eclipse.ui.internal.WorkbenchPage.closeEditors(WorkbenchPage.java:1348)
	at org.eclipse.ui.internal.WorkbenchPage.closeEditor(WorkbenchPage.java:1435)
	at org.eclipse.ui.internal.EditorPane.doHide(EditorPane.java:61)
	at org.eclipse.ui.internal.PartStack.close(PartStack.java:543)
	at org.eclipse.ui.internal.EditorStack.close(EditorStack.java:206)
	at org.eclipse.ui.internal.PartStack$1.close(PartStack.java:122)
	at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation$1.handleEvent(TabbedStackPresentation.java:83)
	at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.fireEvent(AbstractTabFolder.java:270)
	at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.fireEvent(AbstractTabFolder.java:279)
	at org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder.access$1(DefaultTabFolder.java:1)
	at org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder$1.closeButtonPressed(DefaultTabFolder.java:70)
	at org.eclipse.ui.internal.presentations.PaneFolder.notifyCloseListeners(PaneFolder.java:626)
	at org.eclipse.ui.internal.presentations.PaneFolder$3.close(PaneFolder.java:206)
	at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:2199)
	at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:327)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3880)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3473)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at com.mycompany.myapp.client.app.rcp.Application.start(Application.java:29)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
	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:368)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	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:592)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
Comment 2 Paul Webster CLA 2009-11-25 12:42:28 EST

*** This bug has been marked as a duplicate of bug 274554 ***