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
If a Java class contains a static import for javax.ws.rs.core.MediaType.APPLICATION_JSON then applying the recipe 'migrate-jax-rs' fails with ClassCastException
To Reproduce
Steps to reproduce the behavior:
Go to PersonController (src/test/resources/testcode/bootify-jaxrs/src/main/java/com/example/jee/app/PersonController.java in module spring-shell)
Replace @Consumes(MediaType.APPLICATION_JSON) on line 22 by a static import
Run MigrateJaxRsAnnotationsRecipeIntegrationTest
See error
Expected behavior
The JAX-RS classes are migrated and the integration test succeeds.
Stacktrace
ERROR o.s.s.o.RewriteExecutionContext - org.springframework.sbm.java.refactoring.JavaGlobalRefactoringImpl: Exception occured!
org.openrewrite.UncaughtVisitorException: java.lang.ClassCastException: class org.openrewrite.java.tree.J$Identifier cannot be cast to class org.openrewrite.java.tree.J$FieldAccess (org.openrewrite.java.tree.J$Identifier and org.openrewrite.java.tree.J$FieldAccess are in unnamed module of loader 'app')
at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:253)
at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:240)
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$Identifier cannot be cast to class org.openrewrite.java.tree.J$FieldAccess (org.openrewrite.java.tree.J$Identifier and org.openrewrite.java.tree.J$FieldAccess are in unnamed module of loader 'app')
at org.openrewrite.java.tree.J$Import.getTypeName(J.java:2438)
at org.openrewrite.java.RemoveImport.lambda$visitCompilationUnit$1(RemoveImport.java:118)
at org.openrewrite.internal.ListUtils.lambda$flatMap$1(ListUtils.java:199)
at org.openrewrite.internal.ListUtils.flatMap(ListUtils.java:153)
at org.openrewrite.internal.ListUtils.flatMap(ListUtils.java:199)
at org.openrewrite.java.RemoveImport.visitCompilationUnit(RemoveImport.java:112)
at org.openrewrite.java.RemoveImport.visitCompilationUnit(RemoveImport.java:32)
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)
... 10 common frames omitted
Desktop (please complete the following information):
OS: Windows
Version 11 22H2
The text was updated successfully, but these errors were encountered:
Describe the bug
If a Java class contains a static import for
javax.ws.rs.core.MediaType.APPLICATION_JSON
then applying the recipe 'migrate-jax-rs' fails withClassCastException
To Reproduce
Steps to reproduce the behavior:
PersonController
(src/test/resources/testcode/bootify-jaxrs/src/main/java/com/example/jee/app/PersonController.java in module spring-shell)@Consumes(MediaType.APPLICATION_JSON)
on line 22 by a static importMigrateJaxRsAnnotationsRecipeIntegrationTest
Expected behavior
The JAX-RS classes are migrated and the integration test succeeds.
Stacktrace
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: