分析以下Java Annotation类文件时,Sonar会抛出NullPointerException:
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface MyAnnotation
{
String description() default "MyAnnotation";
int order() default Integer.MAX_VALUE;
boolean continueOnFailure() default false;
}
堆栈追踪:
[21:43:44] : [Step 5/5] Caused by: org.sonar.squidbridge.api.AnalysisException: SonarQube is unable to analyze file : '/media/ebs_data0/data/TeamCity/buildAgents/1/work/6863f0261204b044/..../MyAnnotation.java'
[21:43:44] : [Step 5/5] at org.sonar.java.ast.AstScanner.simpleScan(AstScanner.java:115)
[21:43:44] : [Step 5/5] at org.sonar.java.ast.AstScanner.scan(AstScanner.java:76)
[21:43:44] : [Step 5/5] at org.sonar.java.JavaSquid.scanSources(JavaSquid.java:136)
[21:43:44] : [Step 5/5] at org.sonar.java.JavaSquid.scan(JavaSquid.java:129)
.......
[21:43:44] : [Step 5/5] at org.sonar.runner.api.Runner.execute(Runner.java:100)
[21:43:44] : [Step 5/5] at org.codehaus.mojo.sonar.bootstrap.RunnerBootstraper.execute(RunnerBootstraper.java:135)
[21:43:44] : [Step 5/5] ... 22 more
[21:43:44] : [Step 5/5] Caused by: java.lang.NullPointerException
[21:43:44] : [Step 5/5] at org.sonar.java.checks.LeftCurlyBraceStartLineCheck.visitNode(LeftCurlyBraceStartLineCheck.java:43)
[21:43:44] : [Step 5/5] at com.sonar.sslr.impl.ast.AstWalker.visitNode(AstWalker.java:114)
[21:43:44] : [Step 5/5] at com.sonar.sslr.impl.ast.AstWalker.visit(AstWalker.java:85)
[21:43:44] : [Step 5/5] at com.sonar.sslr.impl.ast.AstWalker.visitChildren(AstWalker.java:99)
[21:43:44] : [Step 5/5] at com.sonar.sslr.impl.ast.AstWalker.visit(AstWalker.java:87)
[21:43:44] : [Step 5/5] at com.sonar.sslr.impl.ast.AstWalker.visitChildren(AstWalker.java:99)
[21:43:44] : [Step 5/5] at com.sonar.sslr.impl.ast.AstWalker.visit(AstWalker.java:87)
[21:43:44] : [Step 5/5] at com.sonar.sslr.impl.ast.AstWalker.walkAndVisit(AstWalker.java:69)
[21:43:44] : [Step 5/5] at org.sonar.java.ast.AstScanner.simpleScan(AstScanner.java:108)
[21:43:44] : [Step 5/5] ... 58 more
通过我们的Teamcity服务器中的mvn sonar:sonar -X
调用Sonar来生成上述堆栈跟踪。
有谁知道如何解决这个问题?