SonarCloud analysis failed with NullPointerException

Since January 7, 2020, all our Jenkins build are failing on the Sonar analysis step, always on the same Java test class.

We’re using SonarCloud, we haven’t modified the file since October, and the error log is :

org.sonar.java.AnalysisException: SonarQube is unable to analyze file : '...'
	at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:108)
	at org.sonar.java.ast.JavaAstScanner.scan(JavaAstScanner.java:65)
	at org.sonar.java.JavaSquid.scanTests(JavaSquid.java:117)
	at org.sonar.java.JavaSquid.scan(JavaSquid.java:106)

Caused by: java.lang.NullPointerException at org.eclipse.jdt.core.dom.DefaultBindingResolver.lookupEnvironment(DefaultBindingResolver.java:605)
	at org.eclipse.jdt.core.dom.ASTUtils.mayTolerateMissingType(ASTUtils.java:36)
	at org.sonar.java.model.JParser.parse(JParser.java:315)
	at org.sonar.java.model.JParser.parse(JParser.java:249)
	at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:93)

I can’t give you any reproduction step, but maybe I can give some piece of code to help you ?

Hello @Helayxa,

Thanks for the feedback. It is most probably related to the update of SonarCloud from SonarJava version 5.14 to 6.0 (and now 6.0.1).

In order to help you, could you share the test class code? You can send it to me privately if needed.
If you also manage to reduce the case to a small self-contained reproducer (without dependencies to code outside of the JDK), it would also help quite a lot.

  • Is this test class particularly different from others?
  • Is it the first test class to be analyzed which fails, or it is in the middle of the analysis?
  • Which scanner are you using for your analysis? (maven / gradle / sonar-scanner)

As a temporarily workaround, I would advise to temporarily exclude the test class from analysis, while we are investigating the issue and trying to reproduce it on our side.

Cheers,
Michael

Hi @Michael

Thanks a lot for your answer !
I’m still investigating about this issue (to give you the maximum of reproduction informations), but I can’t publish some code here. How can I contact you privately to give it to you ?

Thanks a lot.
Axel

I sent you a private message regarding this :slight_smile: