Skip to content

Commit 866f021

Browse files
committed
Fix possible ClassCastException and cleanup warnings in NoRequestMappingAnnotation
1 parent 0bb7731 commit 866f021

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/java/org/openrewrite/java/spring/RemoveMethodInvocationsVisitor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@
3333
import static org.openrewrite.Tree.randomId;
3434

3535
/**
36-
* This visitor can remove the specified method calls if it can be deleted without compile error,
37-
* It can be used to remove deprecated or unnecessary method calls, but be sure to carefully
38-
* review your code before deleting any methods to avoid errors or unexpected behavior.
36+
* This visitor removes method calls matching some criteria.
37+
* Tries to intelligently remove within chains without breaking other methods in the chain.
3938
*/
4039
public class RemoveMethodInvocationsVisitor extends JavaVisitor<ExecutionContext> {
4140
private final Map<MethodMatcher, Predicate<List<Expression>>> matchers;
@@ -64,7 +63,8 @@ public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx)
6463
j = j.withPrefix(method.getPrefix());
6564
}
6665

67-
if (method.getArguments().stream().allMatch(ToBeRemoved::hasMarker)) {
66+
// There should always be
67+
if (!method.getArguments().isEmpty() && method.getArguments().stream().allMatch(ToBeRemoved::hasMarker)) {
6868
return ToBeRemoved.withMarker(j);
6969
}
7070
return j;

0 commit comments

Comments
 (0)