-
Type:
Bug
-
Status: Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 5.5.2
-
Fix Version/s: 5.6
-
Component/s: None
-
Labels:None
In some situations, editors have no annotationModel.
One way to reproduce is by opening past versions (either from Git history, or from local history) of an Asciidoc file, using asciidoctor editor.
java.lang.NullPointerException: Cannot invoke "org.eclipse.jface.text.source.IAnnotationModel.getAnnotationIterator()" because "annotationModel" is null at org.sonarlint.eclipse.ui.internal.flowlocations.SonarLintFlowAnnotator.existingFlowAnnotations(SonarLintFlowAnnotator.java:231) at org.sonarlint.eclipse.ui.internal.flowlocations.SonarLintFlowAnnotator.updateFlowAnnotations(SonarLintFlowAnnotator.java:176) at org.sonarlint.eclipse.ui.internal.flowlocations.SonarLintFlowAnnotator.<init>(SonarLintFlowAnnotator.java:145) at org.sonarlint.eclipse.ui.internal.flowlocations.SonarLintFlowAnnotator$1.partActivated(SonarLintFlowAnnotator.java:66) at org.eclipse.ui.internal.WorkbenchPage$4.run(WorkbenchPage.java:4903) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) at org.eclipse.ui.internal.WorkbenchPage.firePartActivated(WorkbenchPage.java:4900) at org.eclipse.ui.internal.WorkbenchPage$E4PartListener.partActivated(WorkbenchPage.java:219) at org.eclipse.e4.ui.internal.workbench.PartServiceImpl$2.run(PartServiceImpl.java:249) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.firePartActivated(PartServiceImpl.java:246) at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:770) at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:679) at org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer.activate(AbstractPartRenderer.java:97) at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.lambda$4(StackRenderer.java:979) at org.eclipse.swt.events.SelectionListener$1.widgetSelected(SelectionListener.java:84) 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:4209) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1037) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1046) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:760) at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3241) at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1879) at org.eclipse.swt.custom.CTabFolder.lambda$0(CTabFolder.java:330) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4209) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1037) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4026) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3626) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1157) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155) at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:644) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:551) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:156) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590) at org.eclipse.equinox.launcher.Main.run(Main.java:1461)
I was not able to reproduce with a Java file, but since the JavaDoc says that this API may returns null, I think we can safely add a null check and don't try to create annotations.
- links to