Skip to content

Commit 657ebd5

Browse files
author
bhavanapidapa
committed
Fixed the code as mentioned in comments
1 parent e3574fc commit 657ebd5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/main/java/org/openrewrite/java/migrate/ArrayStoreExceptionToTypeNotPresentException.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
public class ArrayStoreExceptionToTypeNotPresentException extends Recipe {
3232
@Override
3333
public String getDisplayName() {
34-
return "ArrayStoreExceptionToTypeNotPresentException";
34+
return "ArrayStoreException to TypeNotPresentException around getAnnotation() method ";
3535
}
3636

3737
@Override
@@ -46,8 +46,10 @@ public TreeVisitor<?, ExecutionContext> getVisitor() {
4646

4747
@Override
4848
public J visitTry(J.Try tryStmt, ExecutionContext ctx) {
49+
if (!containsGetAnnotation(tryStmt)) {
50+
return super.visitTry(tryStmt, ctx);
51+
}
4952
boolean flag = false;
50-
if (containsGetAnnotation(tryStmt)) {
5153
List<J.Try.Catch> updatedCatches = new ArrayList<>();
5254
for (J.Try.Catch catchClause : tryStmt.getCatches()) {
5355
if (catchClause.getParameter().getType() != null && catchClause.getParameter().getType().isAssignableFrom(Pattern.compile("java.lang.ArrayStoreException"))) {
@@ -61,7 +63,6 @@ public J visitTry(J.Try tryStmt, ExecutionContext ctx) {
6163
if (flag) {
6264
tryStmt = tryStmt.withCatches(updatedCatches);
6365
}
64-
}
6566
return super.visitTry(tryStmt, ctx);
6667
}
6768

0 commit comments

Comments
 (0)