SonarLint analysis blocks autobuild

The SonarLint analysis currently blocks the autobuild (SonarLint for Eclipse 4.1.0.201901311043). This mostly goes unnoticed because the analysis is fast, but causes issues if it’s long running (e.g. when it’s waiting for a binding update).

We sporadically see commits causing compilation errors that were not shown in eclipse.

To reproduce:

  1. set a breakpoint in AbstractAnalyzeProjectJob::run to simulate a slow analysis
  2. modify and save a java file
    2.1. autobuild runs correctly
    2.2. breakpoint is hit
  3. add a compile error and save again
    3.1. eclipse doesn’t show any error indicator in the package explorer or the problem view

The opened editor does show compile errors in the file, but any errors caused in other files are missed. Also there is no indication, that the build is currently blocked (i.e. no build job with “waiting for … status”).

The build is blocked, because the whole analyze job runs in a workspace operation. The autobuild doesn’t start before all workspace operations have finished.

I think only the actual marker changes should be executed in a workspace operation, not the analysis itself. I can submit a PR, if you want.

Hi @Julian_Honnen

Thanks for the investigation. I’m a bit concerned about consistency of analyses (like what if we try to report an issue on a line that have been already changed), but please go ahead with a PR, I will happily review it.

Thanks for the quick reply!

I don’t think the change would influence consistency in any way, because that’s not provided by workspace operations (–> you can already freely modify the file while the analysis is running).

If you’d want consistency, the job would need a scheduling rule for the analyzed files. But that would obviously degrade usability, as the analysis would then block any modification…

For future reference, ticket created: https://jira.sonarsource.com/browse/SLE-307

@Julian_Honnen

Sorry, I should have started by that in the first place: I’m not able to reproduce the behavior.

What I have:

  • simple Java project in Eclipse Photon 4.8, with latest SonarLint master (should be similar to latest release)
  • created 2 classes, with one class calling a method of the other class
  • put a breakpoint in AbstractAnalyzeProjectJob::doRun
  • change signature of the method, save
  • I can see a background task named SonarLint processing file xxxx that is stuck
  • still it seems autobuild triggered because I can see the compile error displayed on the other class

Can you give me more details on how to reproduce? Should the two classes be in different projects maybe?

The first save triggers an autobuild correctly (i.e. the sonar job runs after the autobuild). The second modification/save then is blocked by the sonar job (which is still stuck on the breakpoint).

Got it, thanks