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

Bug 186727

Summary: [ErrorHandling] NullPointerException when trying to show a Status with OK severity
Product: [Eclipse Project] Platform Reporter: Elias Volanakis <elias>
Component: UIAssignee: Szymon Brandys <Szymon.Brandys>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: P3 CC: eclipse, krzysztof.daniel
Version: 3.3   
Target Milestone: 3.3 RC1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Sample plug-in containing an action that exposes this issue.
none
Fix 01
none
Sample plug-in that does BLOCK and SHOW none

Description Elias Volanakis CLA 2007-05-13 20:17:38 EDT
When trying to show a status instastance that has the severity IStatus.OK, I get an NullPointerException as shown below.

IStatus status = new Status( IStatus.OK, // severity
                             Activator.PLUGIN_ID, 
                             IStatus.OK, 
                             "Message", 
                             null );
StatusManager.getManager().handle( status, StatusManager.SHOW );

Produces the following exception:

org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException)
	at org.eclipse.swt.SWT.error(SWT.java:3547)
	at org.eclipse.swt.SWT.error(SWT.java:3465)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:126)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3650)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3287)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2365)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2329)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2204)
	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.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
	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(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:497)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:436)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1162)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1137)
Caused by: java.lang.NullPointerException
	at org.eclipse.ui.internal.statushandlers.StatusNotificationManager$3.run(StatusNotificationManager.java:134)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123)
	... 23 more

Interestingly, if one changes the severity to IStatus.ERROR the status is handled correctly (e.g. the dialog is shown). BTW, I am not using any custom error handler.
Comment 1 Elias Volanakis CLA 2007-05-13 20:20:39 EDT
Created attachment 66998 [details]
Sample plug-in containing an action that exposes this issue.
Comment 2 Elias Volanakis CLA 2007-05-13 20:23:39 EDT
BTW, I'm using Eclipse 3.3 M7.
Comment 3 Szymon Brandys CLA 2007-05-16 14:55:26 EDT
Created attachment 67482 [details]
Fix 01
Comment 4 Tod Creasey CLA 2007-05-16 15:05:25 EDT
+1
Comment 5 Tod Creasey CLA 2007-05-16 15:07:00 EDT
Created attachment 67484 [details]
Sample plug-in that does BLOCK and SHOW
Comment 6 Tod Creasey CLA 2007-05-16 15:35:04 EDT
Patch released for build >20070516
Comment 7 Elias Volanakis CLA 2007-05-18 14:57:31 EDT
Great, thanks for fixing this! 
Comment 8 Krzysztof Daniel CLA 2009-02-09 06:37:37 EST
Elias, could you tell me what do you expect from StatusManager when you try to handle OK status? This is rather unusual scenario, as you should not notify the user about successfully completed action... I understand that NPE is a bug, but I am really not sure if OK status should be displayed...
Comment 9 Elias Volanakis CLA 2009-02-09 13:18:56 EST
Hi Christopher,

> what do you expect from StatusManager when you try to handle OK status?

if I recall correctly the bug was fixed in 2007.

My expectation was that the status manager would do whatever he does for all other statuses. I though that handling an OK status with StatusManager.LOG is perfectly reasonable, as it provides a centralized way to log stuff and also notifies ILogListeners...

HTH,
Elias.




Comment 10 Krzysztof Daniel CLA 2009-02-09 16:25:39 EST
Yes, this bug was fixed but introduced another one (bug 211933).

But since you are relying on this behavior I will not change it.