Skip to content

Commit 81fb1c9

Browse files
committed
Added null check
1 parent 36fe591 commit 81fb1c9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/java/org/openrewrite/staticanalysis/FallThroughVisitor.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,11 @@ private boolean isFinalTrue(Expression condition) {
291291
List<Statement> statements = ((J.Case) value).getStatements();
292292
declaration = finalVariableDeclaration(statements, id);
293293
} else if (value instanceof J.MethodDeclaration) {
294-
List<Statement> statements = ((J.MethodDeclaration) value).getBody().getStatements();
295-
declaration = finalVariableDeclaration(statements, id);
294+
J.Block body = ((J.MethodDeclaration) value).getBody();
295+
if(body != null) {
296+
List<Statement> statements = body.getStatements();
297+
declaration = finalVariableDeclaration(statements, id);
298+
}
296299
} else if (value instanceof J.ClassDeclaration) {
297300
List<Statement> statements = ((J.ClassDeclaration) value).getBody().getStatements();
298301
declaration = finalVariableDeclaration(statements, id);

0 commit comments

Comments
 (0)