Project: Eclipse_Platform_UI
Bug 101152 [Progress] [regression]RC3 loops with NPE when 2 jobs fail with ERROR status
Reported: 2005-06-21 17:18:06 | Status: verified fixed

I hava a plugin that runs a Job (which I have configured for testing purposes) to fail with an IStatus.ERROR (via setJobStatus in its progress monitor). The second job that is run (and fails with an ERROR status) causes Eclipse to go into an infinite loop reporting a NullPointerException as shown in the .log file excerpt below. One must stop the Eclipse process (e.g. via Windows Task Manager), closing the workspace does not stop the process. The only workaround I've found in my code is to change all job return ERROR status values to WARNING. The code works correctly in 3.1M7 and fails in 3.1RC2 and RC3 (we just discovered this today). In RC3, the NPE occurs in JobErrorDialog.refresh() because the "dialogArea" field is null, but the "dialog" field of the ErrorNotificationManager is not null. Tracing throguh the logic my program executed, the key difference seems to be in ErrorNotificationManager.openErrorDialog -- in M7 the "dialog" field was cleared while in RC3 it is not. Since I have no insight into the rationale for the changes, I'll leave it to the Eclipse developers to analyze further, but this should point you to a likely piece of code. !SESSION 2005-06-21 13:03:15.343 ----------------------------------------------- eclipse.buildId=I20050617-1618 java.version=1.4.2_07 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US Command-line arguments: -os win32 -ws win32 -arch x86 !ENTRY org.eclipse.ui 4 4 2005-06-21 13:04:22.375 !MESSAGE Unhandled event loop exception !ENTRY org.eclipse.ui 4 0 2005-06-21 13:04:22.375 !MESSAGE Failed to execute runnable (java.lang.NullPointerException) !STACK 0 org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException) at org.eclipse.swt.SWT.error(SWT.java:2940) at org.eclipse.swt.SWT.error(SWT.java:2863) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:121) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3047) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2706) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1699) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:367) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163) 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:324) at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334) at org.eclipse.core.launcher.Main.basicRun(Main.java:278) at org.eclipse.core.launcher.Main.run(Main.java:973) at org.eclipse.core.launcher.Main.main(Main.java:948) Caused by: java.lang.NullPointerException at org.eclipse.ui.internal.progress.JobErrorDialog.refresh(JobErrorDialog.java:96) at org.eclipse.ui.internal.progress.ErrorNotificationManager$2.runInUIThread(ErrorNotificationManager.java:113) at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:93) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:118) ... 18 more !ENTRY org.eclipse.ui 4 4 2005-06-21 13:04:22.375 !MESSAGE Unhandled event loop exception !ENTRY org.eclipse.ui 4 0 2005-06-21 13:04:22.391 !MESSAGE Failed to execute runnable (java.lang.NullPointerException) !STACK 0 org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException) at org.eclipse.swt.SWT.error(SWT.java:2940) at org.eclipse.swt.SWT.error(SWT.java:2863) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:121) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3047) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2706) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1699) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:367) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163) 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:324) at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334) at org.eclipse.core.launcher.Main.basicRun(Main.java:278) at org.eclipse.core.launcher.Main.run(Main.java:973) at org.eclipse.core.launcher.Main.main(Main.java:948) Caused by: java.lang.NullPointerException at org.eclipse.ui.internal.progress.JobErrorDialog.refresh(JobErrorDialog.java:96) at org.eclipse.ui.internal.progress.ErrorNotificationManager$2.runInUIThread(ErrorNotificationManager.java:113) at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:93) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:118) ... 18 more !ENTRY org.eclipse.ui 4 4 2005-06-21 13:04:22.391 !MESSAGE Unhandled event loop exception !ENTRY org.eclipse.ui 4 0 2005-06-21 13:04:22.391 !MESSAGE Failed to execute runnable (java.lang.NullPointerException) !STACK 0 org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException) at org.eclipse.swt.SWT.error(SWT.java:2940) at org.eclipse.swt.SWT.error(SWT.java:2863) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:121) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3047) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2706) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1699) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:367) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163) 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:324) at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334) at org.eclipse.core.launcher.Main.basicRun(Main.java:278) at org.eclipse.core.launcher.Main.run(Main.java:973) at org.eclipse.core.launcher.Main.main(Main.java:948) Caused by: java.lang.NullPointerException at org.eclipse.ui.internal.progress.JobErrorDialog.refresh(JobErrorDialog.java:96) at org.eclipse.ui.internal.progress.ErrorNotificationManager$2.runInUIThread(ErrorNotificationManager.java:113) at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:93) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:118) ... 18 more !ENTRY org.eclipse.ui 4 4 2005-06-21 13:04:22.391 !MESSAGE Unhandled event loop exception org.eclipse.ui.internal.progress.ErrorNotificationManager M7 private IStatus openErrorDialog(String title, String msg, final ErrorInfo errorInfo) { IWorkbench workbench = PlatformUI.getWorkbench(); //Abort on shutdown if (workbench instanceof Workbench && ((Workbench) workbench).isClosing()) return Status.CANCEL_STATUS; dialog = new JobErrorDialog(ProgressManagerUtil.getNonModalShell(), title, msg, errorInfo, IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR); try { dialog.open(); } finally { dialog = null; clearAllErrors(); } return Status.OK_STATUS; } RC3 private IStatus openErrorDialog(String title, String msg, final ErrorInfo errorInfo) { IWorkbench workbench = PlatformUI.getWorkbench(); //Abort on shutdown if (workbench instanceof Workbench && ((Workbench) workbench).isClosing()) return Status.CANCEL_STATUS; dialog = new JobErrorDialog(ProgressManagerUtil.getNonModalShell(), title, msg, errorInfo, IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR); dialog.open(); return Status.OK_STATUS; } org.eclipse.ui.internal.progress.JobErrorDialog void refresh() { if(AUTOMATED_MODE)//Nothing to refresh if we never opened it return; if (isMultipleJobErrors()) { if (jobListViewer == null && !dialogArea.isDisposed()) { <==== NPE here due to dialogArea == null // The job list doesn't exist so create it. setMessage(ProgressMessages.JobErrorDialog_MultipleErrorsMessage); getShell().setText(ProgressMessages.JobErrorDialog_MultipleErrorsTitle); createJobListArea((Composite)dialogArea); showDetailsArea(); } refreshJobList(); } updateEnablements(); }

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