You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When I apply the recipe migrate-jax-rs on our Spring Boot 2.5 project, then I get ClassCastExceptions and NullPointerExceptions.
Stacktrace
ERROR o.s.s.o.RewriteExecutionContext - Exception occured!
org.openrewrite.UncaughtVisitorException: java.lang.ClassCastException: class org.openrewrite.java.tree.J$FieldAccess cannot be cast to class org.openrewrite.java.tree.J$Identifier (org.openrewrite.java.tree.J$FieldAccess and org.openrewrite.java.tree.J$Identifier are in unnamed module of loader org.springframework.boot.loader.LaunchedURLClassLoader @198e2867)
at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:253)
at org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:285)
at org.openrewrite.java.JavaVisitor.visitFieldAccess(JavaVisitor.java:575)
at org.springframework.sbm.java.migration.recipes.FindReplaceFieldAccessors$1.visitFieldAccess(FindReplaceFieldAccessors.java:64)
at org.springframework.sbm.java.migration.recipes.FindReplaceFieldAccessors$1.visitFieldAccess(FindReplaceFieldAccessors.java:60)
at org.openrewrite.java.tree.J$FieldAccess.acceptJava(J.java:1735)
at org.openrewrite.java.tree.J.accept(J.java:60)
at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:206)
at org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:285)
at org.openrewrite.java.JavaVisitor.visitImport(JavaVisitor.java:674)
at org.openrewrite.java.tree.J$Import.acceptJava(J.java:2395)
at org.openrewrite.java.tree.J.accept(J.java:60)
at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:206)
at org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:285)
at org.openrewrite.java.JavaVisitor.visitRightPadded(JavaVisitor.java:1226)
at org.openrewrite.java.JavaVisitor.lambda$visitCompilationUnit$9(JavaVisitor.java:465)
at org.openrewrite.internal.ListUtils.lambda$map$0(ListUtils.java:141)
at org.openrewrite.internal.ListUtils.map(ListUtils.java:123)
at org.openrewrite.internal.ListUtils.map(ListUtils.java:141)
at org.openrewrite.java.JavaVisitor.visitCompilationUnit(JavaVisitor.java:465)
at org.openrewrite.java.JavaVisitor.visitJavaSourceFile(JavaVisitor.java:454)
at org.openrewrite.java.tree.J$CompilationUnit.acceptJava(J.java:1351)
at org.openrewrite.java.tree.J.accept(J.java:60)
at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:206)
at org.openrewrite.RecipeScheduler.lambda$scheduleVisit$5(RecipeScheduler.java:241)
at org.openrewrite.RecipeScheduler.lambda$mapAsync$0(RecipeScheduler.java:49)
at org.openrewrite.scheduling.ForkJoinScheduler.lambda$schedule$0(ForkJoinScheduler.java:41)
at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1375)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: java.lang.ClassCastException: class org.openrewrite.java.tree.J$FieldAccess cannot be cast to class org.openrewrite.java.tree.J$Identifier (org.openrewrite.java.tree.J$FieldAccess and org.openrewrite.java.tree.J$Identifier are in unnamed module of loader org.springframework.boot.loader.LaunchedURLClassLoader @198e2867)
at org.openrewrite.java.tree.J$FieldAccess.getName(J.java:1721)
at org.springframework.sbm.java.migration.recipes.FindReplaceFieldAccessors$1.visitFieldAccess(FindReplaceFieldAccessors.java:68)
at org.springframework.sbm.java.migration.recipes.FindReplaceFieldAccessors$1.visitFieldAccess(FindReplaceFieldAccessors.java:60)
at org.openrewrite.java.tree.J$FieldAccess.acceptJava(J.java:1735)
at org.openrewrite.java.tree.J.accept(J.java:60)
at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:206)
... 32 common frames omitted
ERROR o.s.s.o.RewriteExecutionContext - Exception occured!
org.openrewrite.UncaughtVisitorException: java.lang.NullPointerException: Cannot invoke "org.openrewrite.java.tree.Expression.getMarkers()" because the return value of "org.openrewrite.java.tree.J$Return.getExpression()" is null
at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:253)
at org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:285)
at org.openrewrite.java.JavaVisitor.visitRightPadded(JavaVisitor.java:1226)
at org.openrewrite.java.JavaVisitor.lambda$visitBlock$4(JavaVisitor.java:367)
at org.openrewrite.internal.ListUtils.lambda$map$0(ListUtils.java:141)
at org.openrewrite.internal.ListUtils.map(ListUtils.java:123)
at org.openrewrite.internal.ListUtils.map(ListUtils.java:141)
at org.openrewrite.java.JavaVisitor.visitBlock(JavaVisitor.java:366)
at org.openrewrite.java.JavaIsoVisitor.visitBlock(JavaIsoVisitor.java:94)
at org.openrewrite.java.JavaIsoVisitor.visitBlock(JavaIsoVisitor.java:31)
at org.openrewrite.java.tree.J$Block.acceptJava(J.java:745)
at org.openrewrite.java.tree.J.accept(J.java:60)
at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:206)
at org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:285)
at org.openrewrite.java.JavaVisitor.visitRightPadded(JavaVisitor.java:1226)
at org.openrewrite.java.JavaVisitor.visitIf(JavaVisitor.java:664)
at org.openrewrite.java.JavaIsoVisitor.visitIf(JavaIsoVisitor.java:190)
at org.openrewrite.java.JavaIsoVisitor.visitIf(JavaIsoVisitor.java:31)
at org.openrewrite.java.tree.J$If.acceptJava(J.java:2253)
at org.openrewrite.java.tree.J.accept(J.java:60)
at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:206)
at org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:285)
at org.openrewrite.java.JavaVisitor.visitRightPadded(JavaVisitor.java:1226)
at org.openrewrite.java.JavaVisitor.lambda$visitBlock$4(JavaVisitor.java:367)
at org.openrewrite.internal.ListUtils.lambda$map$0(ListUtils.java:141)
at org.openrewrite.internal.ListUtils.map(ListUtils.java:123)
at org.openrewrite.internal.ListUtils.map(ListUtils.java:141)
at org.openrewrite.java.JavaVisitor.visitBlock(JavaVisitor.java:366)
at org.openrewrite.java.JavaIsoVisitor.visitBlock(JavaIsoVisitor.java:94)
at org.openrewrite.java.JavaIsoVisitor.visitBlock(JavaIsoVisitor.java:31)
at org.openrewrite.java.tree.J$Block.acceptJava(J.java:745)
at org.openrewrite.java.tree.J.accept(J.java:60)
at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:206)
at org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:285)
at org.openrewrite.java.JavaVisitor.visitMethodDeclaration(JavaVisitor.java:810)
at org.openrewrite.java.JavaIsoVisitor.visitMethodDeclaration(JavaIsoVisitor.java:225)
at org.openrewrite.java.JavaIsoVisitor.visitMethodDeclaration(JavaIsoVisitor.java:31)
at org.openrewrite.java.tree.J$MethodDeclaration.acceptJava(J.java:3221)
at org.openrewrite.java.tree.J.accept(J.java:60)
at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:206)
at org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:285)
at org.openrewrite.java.JavaVisitor.visitRightPadded(JavaVisitor.java:1226)
at org.openrewrite.java.JavaVisitor.lambda$visitBlock$4(JavaVisitor.java:367)
at org.openrewrite.internal.ListUtils.lambda$map$0(ListUtils.java:141)
at org.openrewrite.internal.ListUtils.map(ListUtils.java:123)
at org.openrewrite.internal.ListUtils.map(ListUtils.java:141)
at org.openrewrite.java.JavaVisitor.visitBlock(JavaVisitor.java:366)
at org.openrewrite.java.JavaIsoVisitor.visitBlock(JavaIsoVisitor.java:94)
at org.openrewrite.java.JavaIsoVisitor.visitBlock(JavaIsoVisitor.java:31)
at org.openrewrite.java.tree.J$Block.acceptJava(J.java:745)
at org.openrewrite.java.tree.J.accept(J.java:60)
at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:206)
at org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:285)
at org.openrewrite.java.JavaVisitor.visitClassDeclaration(JavaVisitor.java:447)
at org.openrewrite.java.JavaIsoVisitor.visitClassDeclaration(JavaIsoVisitor.java:114)
at org.openrewrite.java.JavaIsoVisitor.visitClassDeclaration(JavaIsoVisitor.java:31)
at org.openrewrite.java.tree.J$ClassDeclaration.acceptJava(J.java:1069)
at org.openrewrite.java.tree.J.accept(J.java:60)
at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:206)
at org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:285)
at org.openrewrite.java.JavaVisitor.lambda$visitCompilationUnit$10(JavaVisitor.java:466)
at org.openrewrite.internal.ListUtils.lambda$map$0(ListUtils.java:141)
at org.openrewrite.internal.ListUtils.map(ListUtils.java:123)
at org.openrewrite.internal.ListUtils.map(ListUtils.java:141)
at org.openrewrite.java.JavaVisitor.visitCompilationUnit(JavaVisitor.java:466)
at org.openrewrite.java.JavaIsoVisitor.visitCompilationUnit(JavaIsoVisitor.java:119)
at org.openrewrite.java.JavaIsoVisitor.visitCompilationUnit(JavaIsoVisitor.java:31)
at org.openrewrite.java.JavaVisitor.visitJavaSourceFile(JavaVisitor.java:454)
at org.openrewrite.java.JavaIsoVisitor.visitJavaSourceFile(JavaIsoVisitor.java:39)
at org.openrewrite.java.JavaIsoVisitor.visitJavaSourceFile(JavaIsoVisitor.java:31)
at org.openrewrite.java.tree.J$CompilationUnit.acceptJava(J.java:1351)
at org.openrewrite.java.tree.J.accept(J.java:60)
at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:206)
at org.openrewrite.RecipeScheduler.lambda$scheduleVisit$5(RecipeScheduler.java:241)
at org.openrewrite.RecipeScheduler.lambda$mapAsync$0(RecipeScheduler.java:49)
at org.openrewrite.scheduling.ForkJoinScheduler.lambda$schedule$0(ForkJoinScheduler.java:41)
at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1375)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: java.lang.NullPointerException: Cannot invoke "org.openrewrite.java.tree.Expression.getMarkers()" because the return value of "org.openrewrite.java.tree.J$Return.getExpression()" is null
at org.springframework.sbm.java.migration.visitor.VisitorUtils$AdjustTypesFromExpressionMarkers$1.visitReturn(VisitorUtils.java:164)
at org.springframework.sbm.java.migration.visitor.VisitorUtils$AdjustTypesFromExpressionMarkers$1.visitReturn(VisitorUtils.java:159)
at org.openrewrite.java.tree.J$Return.acceptJava(J.java:4417)
at org.openrewrite.java.tree.J.accept(J.java:60)
at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:206)
... 81 common frames omitted
Desktop (please complete the following information):
OS: Windows
Version: 11 21H2
Additional context
Java: graalvm-ce-java17-21.3.3
The text was updated successfully, but these errors were encountered:
Hi @vbotteman
Thanks for reporting and for the demo application!
I gave it a try and migrate-jax-rs does some useful things before it confirms successful execution.
Actually, I doubt that any other elements will be migrated but I didn't check very thoroughly.
The class cast exception comes from inside OpenRewrite. I need to debug a bit more to figure out where it exactly comes from.
Describe the bug
When I apply the recipe migrate-jax-rs on our Spring Boot 2.5 project, then I get ClassCastExceptions and NullPointerExceptions.
Stacktrace
Desktop (please complete the following information):
Additional context
Java: graalvm-ce-java17-21.3.3
The text was updated successfully, but these errors were encountered: