Skip to content

Conversation

@nmck257
Copy link
Contributor

@nmck257 nmck257 commented Jun 7, 2022

…d parent recipe, and adjusted JUnit5BestPractices to use that new recipe instead of a small subset

…d parent recipe, and adjusted JUnit5BestPractices to use that new recipe instead of a small subset
Copy link
Contributor

@tkvangorder tkvangorder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me

@nmck257
Copy link
Contributor Author

nmck257 commented Jun 7, 2022

Investigating the test failures -- some look clearly related to my change (will review), but I can actually replicate some of these failures on the main branch on my machine. Example below.

Any insights?

JUnitFailToAssertJFailTest > singleStaticMethodWithCause() FAILED
    java.lang.AssertionError: Failed to run parse sources or recipe
        at org.openrewrite.RecipeTest$DefaultImpls._get_executionContext_$lambda-0(RecipeTest.kt:36)
        at org.openrewrite.RecipeTest$DefaultImpls$$Lambda$445/0x0000000800e27238.accept(Unknown Source)
        at org.openrewrite.RecipeScheduler.lambda$scheduleVisit$5(RecipeScheduler.java:266)
        at org.openrewrite.RecipeScheduler$$Lambda$584/0x0000000800f4c500.apply(Unknown Source)
        at org.openrewrite.RecipeScheduler.lambda$mapAsync$0(RecipeScheduler.java:49)
        at org.openrewrite.RecipeScheduler$$Lambda$585/0x0000000800f4c768.call(Unknown Source)
        at org.openrewrite.scheduling.DirectScheduler.schedule(DirectScheduler.java:35)
        at org.openrewrite.RecipeScheduler.mapAsync(RecipeScheduler.java:50)
        at org.openrewrite.RecipeScheduler.scheduleVisit(RecipeScheduler.java:204)
        at org.openrewrite.RecipeTest$RecipeSchedulerCheckingExpectedCycles.scheduleVisit(RecipeTest.kt:218)
        at org.openrewrite.RecipeScheduler.scheduleRun(RecipeScheduler.java:86)
        at org.openrewrite.Recipe.run(Recipe.java:288)
        at org.openrewrite.RecipeTest$DefaultImpls.assertChangedBase(RecipeTest.kt:108)
        at org.openrewrite.RecipeTest$DefaultImpls.assertChangedBase(RecipeTest.kt:57)
        at org.openrewrite.java.JavaRecipeTest$DefaultImpls.assertChanged(JavaRecipeTest.kt:66)
        at org.openrewrite.java.testing.assertj.JUnitFailToAssertJFailTest.assertChanged(JUnitFailToAssertJFailTest.kt:23)
        at org.openrewrite.java.JavaRecipeTest$DefaultImpls.assertChanged$default(JavaRecipeTest.kt:49)
        at org.openrewrite.java.testing.assertj.JUnitFailToAssertJFailTest.singleStaticMethodWithCause(JUnitFailToAssertJFailTest.kt:124)
        Caused by:
        java.lang.IllegalStateException: Unable to construct Java11Parser.
            at org.openrewrite.java.Java11Parser$Builder.build(Java11Parser.java:108)
            at org.openrewrite.java.Java11Parser$Builder.build(Java11Parser.java:74)
            at org.openrewrite.java.testing.assertj.JUnitFailToAssertJFail$JUnitFailToAssertJFailVisitor.lambda$static$0(JUnitFailToAssertJFail.java:60)
            at org.openrewrite.java.testing.assertj.JUnitFailToAssertJFail$JUnitFailToAssertJFailVisitor$$Lambda$815/0x0000000800fedc80.get(Unknown Source)
            at org.openrewrite.java.internal.template.JavaTemplateParser.compileTemplate(JavaTemplateParser.java:247)
            at org.openrewrite.java.internal.template.JavaTemplateParser.parseBlockStatements(JavaTemplateParser.java:166)
            at org.openrewrite.java.JavaTemplate$2.maybeReplaceStatement(JavaTemplate.java:475)
            at org.openrewrite.java.JavaTemplate$2.visitMethodInvocation(JavaTemplate.java:455)
            at org.openrewrite.java.JavaTemplate$2.visitMethodInvocation(JavaTemplate.java:103)
            at org.openrewrite.java.tree.J$MethodInvocation.acceptJava(J.java:3295)
            at org.openrewrite.java.tree.J.accept(J.java:53)
            at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:214)
            at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:155)
            at org.openrewrite.java.JavaTemplate.withTemplate(JavaTemplate.java:513)
            at org.openrewrite.java.JavaTemplate.withTemplate(JavaTemplate.java:43)
            at org.openrewrite.java.tree.J.withTemplate(J.java:80)
            at org.openrewrite.java.testing.assertj.JUnitFailToAssertJFail$JUnitFailToAssertJFailVisitor.visitMethodInvocation(JUnitFailToAssertJFail.java:91)
            at org.openrewrite.java.testing.assertj.JUnitFailToAssertJFail$JUnitFailToAssertJFailVisitor.visitMethodInvocation(JUnitFailToAssertJFail.java:58)
            at org.openrewrite.java.tree.J$MethodInvocation.acceptJava(J.java:3295)
            at org.openrewrite.java.tree.J.accept(J.java:53)
            at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:214)
            at org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:288)
            at org.openrewrite.java.JavaVisitor.visitRightPadded(JavaVisitor.java:1233)
            at org.openrewrite.java.JavaVisitor.lambda$visitBlock$4(JavaVisitor.java:372)
            at org.openrewrite.java.JavaVisitor$$Lambda$590/0x0000000800f54230.apply(Unknown Source)
            at org.openrewrite.internal.ListUtils.lambda$map$0(ListUtils.java:138)
            at org.openrewrite.internal.ListUtils$$Lambda$573/0x0000000800e91bd8.apply(Unknown Source)
            at org.openrewrite.internal.ListUtils.map(ListUtils.java:120)
            at org.openrewrite.internal.ListUtils.map(ListUtils.java:138)
            at org.openrewrite.java.JavaVisitor.visitBlock(JavaVisitor.java:371)
            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:720)
            at org.openrewrite.java.tree.J.accept(J.java:53)
            at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:214)
            at org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:288)
            at org.openrewrite.java.JavaVisitor.visitMethodDeclaration(JavaVisitor.java:813)
            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:3042)
            at org.openrewrite.java.tree.J.accept(J.java:53)
            at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:214)
            at org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:288)
            at org.openrewrite.java.JavaVisitor.visitRightPadded(JavaVisitor.java:1233)
            at org.openrewrite.java.JavaVisitor.lambda$visitBlock$4(JavaVisitor.java:372)
            at org.openrewrite.java.JavaVisitor$$Lambda$590/0x0000000800f54230.apply(Unknown Source)
            at org.openrewrite.internal.ListUtils.lambda$map$0(ListUtils.java:138)
            at org.openrewrite.internal.ListUtils$$Lambda$573/0x0000000800e91bd8.apply(Unknown Source)
            at org.openrewrite.internal.ListUtils.map(ListUtils.java:120)
            at org.openrewrite.internal.ListUtils.map(ListUtils.java:138)
            at org.openrewrite.java.JavaVisitor.visitBlock(JavaVisitor.java:371)
            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:720)
            at org.openrewrite.java.tree.J.accept(J.java:53)
            at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:214)
            at org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:288)
            at org.openrewrite.java.JavaVisitor.visitClassDeclaration(JavaVisitor.java:452)
            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:992)
            at org.openrewrite.java.tree.J.accept(J.java:53)
            at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:214)
            at org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:288)
            at org.openrewrite.java.JavaVisitor.lambda$visitCompilationUnit$10(JavaVisitor.java:471)
            at org.openrewrite.java.JavaVisitor$$Lambda$589/0x0000000800f4f988.apply(Unknown Source)
            at org.openrewrite.internal.ListUtils.lambda$map$0(ListUtils.java:138)
            at org.openrewrite.internal.ListUtils$$Lambda$573/0x0000000800e91bd8.apply(Unknown Source)
            at org.openrewrite.internal.ListUtils.map(ListUtils.java:120)
            at org.openrewrite.internal.ListUtils.map(ListUtils.java:138)
            at org.openrewrite.java.JavaVisitor.visitCompilationUnit(JavaVisitor.java:471)
            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:459)
            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:1226)
            at org.openrewrite.java.tree.J.accept(J.java:53)
            at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:214)
            at org.openrewrite.RecipeScheduler.lambda$scheduleVisit$5(RecipeScheduler.java:245)
            ... 15 more
            Caused by:
            java.lang.reflect.InvocationTargetException
                at jdk.internal.reflect.GeneratedConstructorAccessor9.newInstance(Unknown Source)
                at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
                at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
                at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
                at org.openrewrite.java.Java11Parser$Builder.build(Java11Parser.java:104)
                ... 94 more
                Caused by:
                java.lang.IllegalStateException: Call reset() on JavaParser before parsing anotherset of source files that have some of the same fully qualified names
                    at org.openrewrite.java.isolated.ReloadableJava11Parser.lambda$parseInputsToCompilerAst$2(ReloadableJava11Parser.java:244)
                    at org.openrewrite.java.isolated.ReloadableJava11Parser$$Lambda$456/0x0000000800e06df8.get(Unknown Source)
                    at io.micrometer.core.instrument.composite.CompositeTimer.record(CompositeTimer.java:65)
                    at org.openrewrite.java.isolated.ReloadableJava11Parser.parseInputsToCompilerAst(ReloadableJava11Parser.java:239)
                    at org.openrewrite.java.isolated.ReloadableJava11Parser.parseInputs(ReloadableJava11Parser.java:160)
                    at org.openrewrite.java.isolated.ReloadableJava11Parser.compileDependencies(ReloadableJava11Parser.java:312)
                    at org.openrewrite.java.isolated.ReloadableJava11Parser.<init>(ReloadableJava11Parser.java:150)
                    ... 99 more
                    Caused by:
                    java.lang.IllegalStateException: endPosTable already set
                        at com.sun.tools.javac.util.DiagnosticSource.setEndPosTable(DiagnosticSource.java:136)
                        at com.sun.tools.javac.util.Log.setEndPosTable(Log.java:413)
                        at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:659)
                        at org.openrewrite.java.isolated.ReloadableJava11Parser.lambda$parseInputsToCompilerAst$2(ReloadableJava11Parser.java:241)
                        ... 105 more

@tkvangorder
Copy link
Contributor

Hi Nick, I will try to grab some time today to look at this. I am having to context switch a lot today. 8)

@nmck257
Copy link
Contributor Author

nmck257 commented Jun 7, 2022

Hi Nick, I will try to grab some time today to look at this. I am having to context switch a lot today. 8)

Solidarity -- it doesn't have to be today if it's just for my benefit :)

@nmck257
Copy link
Contributor Author

nmck257 commented Jun 21, 2022

@tkvangorder - FYI, I did resolve the test failure associated with my changes (some existing code was vulnerable to class cast exceptions). The CI build looks to only be failing with that JavaParser issue described above now, which I think is unrelated.

@tkvangorder tkvangorder merged commit 30b0de3 into openrewrite:main Jun 29, 2022
@tkvangorder
Copy link
Contributor

Sorry, it took a bit to get to this PR! A lot going on the last couple of weeks

@nmck257
Copy link
Contributor Author

nmck257 commented Jun 29, 2022

Sorry, it took a bit to get to this PR! A lot going on the last couple of weeks

No worries - thanks!

@traceyyoshima traceyyoshima added this to the 1.24.0 milestone Jul 7, 2022
@tkvangorder tkvangorder added the enhancement New feature or request label Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants