NPE in RuleDescriptionWebView in Eclipse / Spring Tools Suite

Hello,

I’m using the latest Sonar Lint release for Eclipse and receive sometimes an NPE if open the rule via the hover in the editor.

Spring Tool Suite 4
Version: 4.4.0.CI-B1961
Build Id: 201908211948
OS: Linux, v.5.0.0-25-generic, x86_64 / gtk 3.24.8, WebKit 2.24.2
Java version: 12.0.1

Unable to open rule description view

java.lang.NullPointerException
	at org.sonarlint.eclipse.ui.internal.views.RuleDescriptionWebView.open(RuleDescriptionWebView.java:287)
	at org.sonarlint.eclipse.ui.internal.views.RuleDescriptionWebView.setInput(RuleDescriptionWebView.java:261)
	at org.sonarlint.eclipse.ui.internal.markers.ShowRuleDescriptionMarkerResolver.run(ShowRuleDescriptionMarkerResolver.java:53)
	at org.eclipse.jdt.internal.ui.text.correction.proposals.MarkerResolutionProposal.apply(MarkerResolutionProposal.java:55)
	at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl.apply(AbstractAnnotationHover.java:569)
	at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl.access$2(AbstractAnnotationHover.java:546)
	at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl$5.widgetSelected(AbstractAnnotationHover.java:540)
	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:5618)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1405)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1431)
	at org.eclipse.swt.widgets.Widget.sendSelectionEvent(Widget.java:1565)
	at org.eclipse.swt.widgets.Link.gtk_button_release_event(Link.java:394)
	at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:2227)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:6846)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5842)
	at org.eclipse.swt.internal.gtk.GTK._gtk_main_do_event(Native Method)
	at org.eclipse.swt.internal.gtk.GTK.gtk_main_do_event(GTK.java:4154)
	at org.eclipse.swt.widgets.Display.eventProc(Display.java:1474)
	at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
	at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:1603)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4404)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1160)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1049)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:633)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:557)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:150)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
	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:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:660)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:597)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1468)

Hi @vogella

I will need more help to understand the issue. First question is: when it happens on a specific issue, can you reproduce it multiple times? Or is it really happening randomly?

Based on the stacktrace, it may depends on the resource the marker belongs to. Can you check the resource name/type. And BTW does the problem also occurs when using the context menu on the SonarLint On-The-Fly view, or only when using the hover?

Unfortunately this only happens from time to time. So far I only had it if I used the hover.

I think the issue was for “@RequestMapping” suggesting that I should use @GetMapping but I cannot produce this anymore (if I change it back, the hover description link works fine).

Totally random guesses:

  • does it happen right after renaming a file?
  • do you switch on/off connected mode? (bind/unbind project)
  • is it the standard Java code editor, or is STS providing a custom editor for some Spring related stuff?