From cec7cd3654ba0c7fc28b1c869cf8b8484c27bc6a Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Thu, 19 Jan 2023 17:30:13 +0100 Subject: [PATCH] Avoid adding the exception itself as a suppressed exception As experienced in #30463, it seems it can happen. --- .../java/io/quarkus/test/junit/QuarkusTestExtension.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java b/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java index fd9153d2010fc..e64a8ace36a76 100644 --- a/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java +++ b/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java @@ -816,8 +816,13 @@ public void interceptTestMethod(Invocation invocation, ReflectiveInvocatio runExtensionMethod(invocationContext, extensionContext, true); invocation.skip(); } catch (Throwable t) { - for (var i : serverExceptions) { - t.addSuppressed(i); + for (var serverException : serverExceptions) { + if (t == serverException) { + // do not add a suppressed exception to itself + continue; + } + + t.addSuppressed(serverException); } throw t; } finally {