Skip to content

Commit

Permalink
Avoid potential for StackOverflow on J#getWeight (#4343)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkschneider authored Jul 19, 2024
1 parent 537d023 commit 105bdab
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions rewrite-java/src/main/java/org/openrewrite/java/tree/J.java
Original file line number Diff line number Diff line change
Expand Up @@ -1528,11 +1528,9 @@ public JavaType visit(@Nullable JavaType javaType, AtomicInteger n) {
};

@Override
public @Nullable J visit(@Nullable Tree tree, AtomicInteger n) {
if (tree != null) {
n.incrementAndGet();
}
return super.visit(tree, n);
public @Nullable J preVisit(J tree, AtomicInteger n) {
n.incrementAndGet();
return tree;
}

@Override
Expand Down

0 comments on commit 105bdab

Please sign in to comment.