From 771e21deba886d2efd42e3168914bc2e5570706f Mon Sep 17 00:00:00 2001 From: Niels de Bruin Date: Thu, 3 Oct 2024 14:27:12 +0200 Subject: [PATCH] Change stream to foreach loop --- .../staticanalysis/CatchClauseOnlyRethrows.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/openrewrite/staticanalysis/CatchClauseOnlyRethrows.java b/src/main/java/org/openrewrite/staticanalysis/CatchClauseOnlyRethrows.java index e947b8a21..87eb10a8d 100755 --- a/src/main/java/org/openrewrite/staticanalysis/CatchClauseOnlyRethrows.java +++ b/src/main/java/org/openrewrite/staticanalysis/CatchClauseOnlyRethrows.java @@ -90,7 +90,12 @@ public J.Try visitTry(J.Try tryable, ExecutionContext ctx) { private boolean hasWiderExceptionType(J.Try.Catch aCatch, J.Try.Catch next) { if (next.getParameter().getType() instanceof JavaType.MultiCatch) { JavaType.MultiCatch multiCatch = (JavaType.MultiCatch) next.getParameter().getType(); - return multiCatch.getThrowableTypes().stream().anyMatch(alt -> TypeUtils.isAssignableTo(alt, aCatch.getParameter().getType())); + for (JavaType throwableType : multiCatch.getThrowableTypes()) { + if (TypeUtils.isAssignableTo(throwableType, aCatch.getParameter().getType())) { + return true; + } + } + return false; } return TypeUtils.isAssignableTo(next.getParameter().getType(), aCatch.getParameter().getType()); }