diff --git a/src/main/java/org/openrewrite/java/migrate/lang/ThreadStopUnsupported.java b/src/main/java/org/openrewrite/java/migrate/lang/ThreadStopUnsupported.java index b9db254bd..28c6819b0 100644 --- a/src/main/java/org/openrewrite/java/migrate/lang/ThreadStopUnsupported.java +++ b/src/main/java/org/openrewrite/java/migrate/lang/ThreadStopUnsupported.java @@ -54,9 +54,7 @@ public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) J j = super.visitMethodInvocation(method, ctx); if (THREAD_STOP_MATCHER.matches(method) || THREAD_RESUME_MATCHER.matches(method) || THREAD_SUSPEND_MATCHER.matches(method)) { if (usesJava21(ctx)) { - JavaTemplate template = JavaTemplate.builder("throw new UnsupportedOperationException()") - .contextSensitive().build(); - j = template.apply(getCursor(), method.getCoordinates().replace()); + j = JavaTemplate.apply("throw new UnsupportedOperationException()", getCursor(), method.getCoordinates().replace()); } if (j.getComments().isEmpty()) { j = getWithComment(j, method.getName().getSimpleName()); diff --git a/src/test/java/org/openrewrite/java/migrate/lang/ThreadStopUnsupportedTest.java b/src/test/java/org/openrewrite/java/migrate/lang/ThreadStopUnsupportedTest.java index e3485e1d2..0dcbd4191 100644 --- a/src/test/java/org/openrewrite/java/migrate/lang/ThreadStopUnsupportedTest.java +++ b/src/test/java/org/openrewrite/java/migrate/lang/ThreadStopUnsupportedTest.java @@ -25,6 +25,7 @@ import static org.openrewrite.java.Assertions.javaVersion; class ThreadStopUnsupportedTest implements RewriteTest { + @Override public void defaults(RecipeSpec spec) { spec.recipe(new ThreadStopUnsupported()); @@ -62,8 +63,6 @@ void bar() { } @Test - @Issue("https://github.com/openrewrite/rewrite-migrate-java/issues/194") - @DocumentExample void retainCommentIfPresent() { rewriteRun( //language=java @@ -82,8 +81,6 @@ void bar() { } @Test - @Issue("https://github.com/openrewrite/rewrite-migrate-java/issues/194") - @DocumentExample void replaceStopWithThrowsOnJava21() { rewriteRun( //language=java @@ -113,8 +110,6 @@ void bar() { } @Test - @Issue("https://github.com/openrewrite/rewrite-migrate-java/issues/194") - @DocumentExample void replaceResumeWithThrowsOnJava21() { rewriteRun( //language=java @@ -144,8 +139,6 @@ void bar() { } @Test - @Issue("https://github.com/openrewrite/rewrite-migrate-java/issues/194") - @DocumentExample void replaceSuspendWithThrowsOnJava21() { rewriteRun( //language=java