Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE in ImmutablesBuilderMissingInitialization #1518

Closed
laflechejonathan opened this issue Oct 21, 2020 · 0 comments · Fixed by #1519
Closed

NPE in ImmutablesBuilderMissingInitialization #1518

laflechejonathan opened this issue Oct 21, 2020 · 0 comments · Fixed by #1519

Comments

@laflechejonathan
Copy link

laflechejonathan commented Oct 21, 2020

What happened?

     error-prone version: 2.4.0
     BugPattern: ImmutablesBuilderMissingInitialization
     Stack Trace:
     java.lang.NullPointerException: Cannot invoke "com.sun.source.tree.BlockTree.getStatements()" because the return value of "com.sun.source.tree.MethodTree.getBody()" is null
  	at com.palantir.baseline.errorprone.ImmutablesBuilderMissingInitialization.methodJustConstructsBuilder(ImmutablesBuilderMissingInitialization.java:244)
  	at com.palantir.baseline.errorprone.ImmutablesBuilderMissingInitialization.checkInitialization(ImmutablesBuilderMissingInitialization.java:170)
  	at com.palantir.baseline.errorprone.ImmutablesBuilderMissingInitialization.matchMethodInvocation(ImmutablesBuilderMissingInitialization.java:132)
  	at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:451)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitMethodInvocation(ErrorProneScanner.java:748)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitMethodInvocation(ErrorProneScanner.java:152)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1761)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:113)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitMethodInvocation(TreeScanner.java:528)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitMethodInvocation(ErrorProneScanner.java:753)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitMethodInvocation(ErrorProneScanner.java:152)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1761)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitExpressionStatement(TreeScanner.java:452)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitExpressionStatement(ErrorProneScanner.java:635)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitExpressionStatement(ErrorProneScanner.java:152)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1540)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)

The offending code looks roughly like:

private void doFoo(FooContext ctx) {
    doCoolThing(ctx.fooBuilder().build());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant