e4: FinishedJobs instance is never injected into ProgressServiceImpl for progress dialogs
My progress monitor dialog throws a NPE when cancelling a sub job in the details view (the red button). I have traced the issue down to the ProgressServiceImpl class where the finishedJobs variable isn´t injected, thus is always null. I tried to download the code from GitHub and use it instead of the plugin in Eclipse 2024-03 (4.31) and by removing the row with @Optional, it suddenly worked just fine.
@Inject
FinishedJobs finishedJobs;
Stack trace: java.lang.NullPointerException: Cannot invoke "org.eclipse.e4.ui.progress.internal.FinishedJobs.isKept(org.eclipse.e4.ui.progress.internal.JobTreeElement)" because "this.finishedJobs" is null at org.eclipse.e4.ui.progress.internal.ProgressInfoItem.cancelOrRemove(ProgressInfoItem.java:308) at org.eclipse.e4.ui.progress.internal.ProgressInfoItem$1.widgetSelected(ProgressInfoItem.java:229) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:252) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4274) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4072) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1151) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1042) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:152) at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:165) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:208) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:143) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:109) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:439) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:271) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:651) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:588) at org.eclipse.equinox.launcher.Main.run(Main.java:1459) at org.eclipse.equinox.launcher.Main.main(Main.java:1432)
I also tried to add a ProgressView to my application to get the jobs listed there. And that works just fine. Probably due to the correctly injected FinishedJobs instance in the view´s createPartControl method (which doesn´t use the @Optional annotation.