CatchClauseOnlyRethrows
should not remove empty catch if the exception then gets caught by another catch block
#4235
Labels
Problem
As can be seen in the example, a catch block is removed that was added for a specific subtype of an exception to just have it rethrown. Now, that the catch block is removed, the exception will get handled by a different catch block, which is the wrong thing to do.
Expected behavior
In this case the recipe should not remove the catch block. Checking for any following catch blocks is the easy fix here.
Example diff
From:
spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/serializer/ByteArraySingleTerminatorSerializer.java
Recipes in example diff:
org.openrewrite.staticanalysis.CatchClauseOnlyRethrows
References:
org.openrewrite.staticanalysis.CatchClauseOnlyRethrows
Catch clause should do more than just rethrow
spring-projects/spring-integration/main
The text was updated successfully, but these errors were encountered: