What version of OpenRewrite are you using?
- org.openrewrite:rewrite-core:jar:8.28.1
- org.openrewrite.recipe:rewrite-testing-frameworks:jar:2.12.2
What is the smallest, simplest way to reproduce the problem?
org.openrewrite.java.testing.junit5.RemoveTryCatchFailBlocks should not try to rewrite in the case where the try {} contains a return, see the test case for an example. This will create non-compiling code since the return is now in the assertDoesNotThrow lambda. We ran into this in our code base.
@Test
void testRemoveTryCatchFailBlocksWithReturningTry() {
rewriteRun(
spec -> spec.recipe(new RemoveTryCatchFailBlocks()),
java(
"""
package com.helloworld;
import static org.junit.jupiter.api.Assertions.fail;
public class Foo {
String getFoo() {
try {
return "foo";
} catch (RuntimeException e) {
fail();
}
}
}"""));
}
What version of OpenRewrite are you using?
What is the smallest, simplest way to reproduce the problem?
org.openrewrite.java.testing.junit5.RemoveTryCatchFailBlocksshould not try to rewrite in the case where thetry {}contains areturn, see the test case for an example. This will create non-compiling code since the return is now in theassertDoesNotThrowlambda. We ran into this in our code base.