Skip to content

Commit dd7ec21

Browse files
committed
Adopt JavaTemplate.apply; drop context sensitive in ThreadStopUnsupported
1 parent 941c654 commit dd7ec21

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

src/main/java/org/openrewrite/java/migrate/lang/ThreadStopUnsupported.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx)
5454
J j = super.visitMethodInvocation(method, ctx);
5555
if (THREAD_STOP_MATCHER.matches(method) || THREAD_RESUME_MATCHER.matches(method) || THREAD_SUSPEND_MATCHER.matches(method)) {
5656
if (usesJava21(ctx)) {
57-
JavaTemplate template = JavaTemplate.builder("throw new UnsupportedOperationException()")
58-
.contextSensitive().build();
59-
j = template.apply(getCursor(), method.getCoordinates().replace());
57+
j = JavaTemplate.apply("throw new UnsupportedOperationException()", getCursor(), method.getCoordinates().replace());
6058
}
6159
if (j.getComments().isEmpty()) {
6260
j = getWithComment(j, method.getName().getSimpleName());

src/test/java/org/openrewrite/java/migrate/lang/ThreadStopUnsupportedTest.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import static org.openrewrite.java.Assertions.javaVersion;
2626

2727
class ThreadStopUnsupportedTest implements RewriteTest {
28+
2829
@Override
2930
public void defaults(RecipeSpec spec) {
3031
spec.recipe(new ThreadStopUnsupported());
@@ -62,8 +63,6 @@ void bar() {
6263
}
6364

6465
@Test
65-
@Issue("https://github.com/openrewrite/rewrite-migrate-java/issues/194")
66-
@DocumentExample
6766
void retainCommentIfPresent() {
6867
rewriteRun(
6968
//language=java
@@ -82,8 +81,6 @@ void bar() {
8281
}
8382

8483
@Test
85-
@Issue("https://github.com/openrewrite/rewrite-migrate-java/issues/194")
86-
@DocumentExample
8784
void replaceStopWithThrowsOnJava21() {
8885
rewriteRun(
8986
//language=java
@@ -113,8 +110,6 @@ void bar() {
113110
}
114111

115112
@Test
116-
@Issue("https://github.com/openrewrite/rewrite-migrate-java/issues/194")
117-
@DocumentExample
118113
void replaceResumeWithThrowsOnJava21() {
119114
rewriteRun(
120115
//language=java
@@ -144,8 +139,6 @@ void bar() {
144139
}
145140

146141
@Test
147-
@Issue("https://github.com/openrewrite/rewrite-migrate-java/issues/194")
148-
@DocumentExample
149142
void replaceSuspendWithThrowsOnJava21() {
150143
rewriteRun(
151144
//language=java

0 commit comments

Comments
 (0)