SonarLint无法使用StringBuffer分析文件(空指针异常)

时间:2016-09-20 03:15:38

标签: java eclipse sonarlint

SonarLint 2.2.1无法分析Eclipse Mars 4.5.2中的以下Java类

public class Temp {
    @FunctionalInterface
    private interface IX {
        void execute(StringBuffer sb);
    }
    static {
        x(sb -> y());
    }
    private static void x(IX parm) {}
    private static void y(){}
}

如果我将StringBuffer更改为其他任何内容,那么就没有问题。

附加说明:用Stack< Object>替换StringBuffer也会导致问题。

这是我看到的转储

    Error during analysis
    org.sonar.squidbridge.api.AnalysisException: SonarQube is unable to analyze file : 'C:\projects\...\Temp.java'
        at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:93)
        at org.sonar.java.ast.JavaAstScanner.scan(JavaAstScanner.java:67)
        at org.sonar.java.JavaSquid.scanSources(JavaSquid.java:119)
        at org.sonar.java.JavaSquid.scan(JavaSquid.java:113)
        at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:87)
        at org.sonarsource.sonarlint.core.analyzer.sensor.SensorWrapper.analyse(SensorWrapper.java:52)
        at org.sonarsource.sonarlint.core.analyzer.sensor.SensorsExecutor.executeSensor(SensorsExecutor.java:73)
        at org.sonarsource.sonarlint.core.analyzer.sensor.SensorsExecutor.execute(SensorsExecutor.java:63)
        at org.sonarsource.sonarlint.core.analyzer.sensor.PhaseExecutor.execute(PhaseExecutor.java:44)
        at org.sonarsource.sonarlint.core.container.analysis.AnalysisContainer.doAfterStart(AnalysisContainer.java:143)
        at org.sonarsource.sonarlint.core.container.ComponentContainer.startComponents(ComponentContainer.java:125)
        at org.sonarsource.sonarlint.core.container.ComponentContainer.execute(ComponentContainer.java:110)
        at org.sonarsource.sonarlint.core.container.standalone.StandaloneGlobalContainer.analyze(StandaloneGlobalContainer.java:118)
        at org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl.analyze(StandaloneSonarLintEngineImpl.java:93)
        at org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl.analyze(StandaloneSonarLintEngineImpl.java:83)
        at org.sonarlint.eclipse.core.internal.jobs.StandaloneSonarLintClientFacade.runAnalysis(StandaloneSonarLintClientFacade.java:60)
        at org.sonarlint.eclipse.core.internal.jobs.AnalyzeProjectJob.run(AnalyzeProjectJob.java:463)
        at org.sonarlint.eclipse.core.internal.jobs.AnalyzeProjectJob$AnalysisThread.run(AnalyzeProjectJob.java:127)
    Caused by: java.lang.NullPointerException
        at org.sonar.java.AnalyzerMessage.textSpanBetween(AnalyzerMessage.java:122)
        at org.sonar.java.AnalyzerMessage.textSpanFor(AnalyzerMessage.java:111)
        at org.sonar.java.model.DefaultJavaFileScannerContext.createAnalyzerMessage(DefaultJavaFileScannerContext.java:133)
        at org.sonar.java.model.DefaultJavaFileScannerContext.reportIssue(DefaultJavaFileScannerContext.java:118)
        at org.sonar.java.model.DefaultJavaFileScannerContext.reportIssue(DefaultJavaFileScannerContext.java:113)
        at org.sonar.plugins.java.api.IssuableSubscriptionVisitor.reportIssue(IssuableSubscriptionVisitor.java:57)
        at org.sonar.java.checks.SynchronizedClassUsageCheck$DeprecatedTypeVisitor.reportIssueOnDeprecatedType(SynchronizedClassUsageCheck.java:102)
        at org.sonar.java.checks.SynchronizedClassUsageCheck$DeprecatedTypeVisitor.visitVariable(SynchronizedClassUsageCheck.java:95)
        at org.sonar.java.model.declaration.VariableTreeImpl.accept(VariableTreeImpl.java:184)
        at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
        at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:37)
        at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitLambdaExpression(BaseTreeVisitor.java:342)
        at org.sonar.java.model.expression.LambdaExpressionTreeImpl.accept(LambdaExpressionTreeImpl.java:91)
        at org.sonar.java.ast.parser.ListTreeImpl.accept(ListTreeImpl.java:63)
        at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
        at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:48)
        at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitMethodInvocation(BaseTreeVisitor.java:252)
        at org.sonar.java.model.expression.MethodInvocationTreeImpl.accept(MethodInvocationTreeImpl.java:96)
        at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
        at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitExpressionStatement(BaseTreeVisitor.java:101)
        at org.sonar.java.model.statement.ExpressionStatementTreeImpl.accept(ExpressionStatementTreeImpl.java:65)
        at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
        at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:37)
        at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBlock(BaseTreeVisitor.java:85)
        at org.sonar.java.model.statement.BlockTreeImpl.accept(BlockTreeImpl.java:77)
        at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
        at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:37)
        at org.sonar.java.checks.SynchronizedClassUsageCheck$DeprecatedTypeVisitor.visitClass(SynchronizedClassUsageCheck.java:73)
        at org.sonar.java.model.declaration.ClassTreeImpl.accept(ClassTreeImpl.java:198)
        at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
        at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:37)
        at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitCompilationUnit(BaseTreeVisitor.java:55)
        at org.sonar.java.model.JavaTree$CompilationUnitTreeImpl.accept(JavaTree.java:184)
        at org.sonar.java.checks.SynchronizedClassUsageCheck.visitNode(SynchronizedClassUsageCheck.java:61)
        at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:95)
        at org.sonar.java.ast.visitors.SubscriptionVisitor.scanTree(SubscriptionVisitor.java:78)
        at org.sonar.java.ast.visitors.SubscriptionVisitor.scanFile(SubscriptionVisitor.java:64)
        at org.sonar.java.model.VisitorsBridge.visitFile(VisitorsBridge.java:123)
        at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:84)
        ... 17 more

1 个答案:

答案 0 :(得分:0)

看起来你正面临Java分析器中的以下错误,这个错误将在即将发布的4.3版本的Java分析器以及即将推出的SonarLint for Eclipse版本中修复:https://jira.sonarsource.com/browse/SONARJAVA-1838 < / p>