NullPointerException when there's no @Rule annotation

14 views
Skip to first unread message

nicolasms...@gmail.com

unread,
Sep 5, 2017, 10:12:46 AM9/5/17
to SonarQube
I'm developing Java custom rules and at one of them I forgot to annotate the class with @Rule. When the tests ran, the only 
message was about a NullPointerException. I thought... It could be anything...

After some debug, I finally found that in the class org.sonar.java.checks.verifier.CheckVerifier, in the method 
private static String ruleKey(AnalyzerMessage issue), inside the else clause, the key is being recovered 
even when the getAnnotation returns null. Then I discovered my mistake.

I want to ask if you could just leave a message that exposes better this error when it occurs.

Thanks! 👍

Michael Gumowski

unread,
Sep 6, 2017, 11:58:29 AM9/6/17
to nicolasms...@gmail.com, SonarQube
Hey Nicolas,

Thanks for the feedback. I've been hit by this one a few time already... and we should have fixed it sooner.
Ticket created: SONARJAVA-2448

Cheers,
Michael

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/2c73e7a9-f914-4072-8987-a224ee5ef182%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Michael Gumowski | SonarSource
Software Developer, Language Team
http://sonarsource.com
Reply all
Reply to author
Forward
0 new messages