From 94c40fc21c974aacd466a2cc7fac4ddd86ddb29b Mon Sep 17 00:00:00 2001 From: Benjamin Confino Date: Tue, 26 Mar 2024 16:22:31 +0000 Subject: [PATCH] preserve first exception in writeObject (#538) The first exception `e` will be unrelated to `e2`, and if we're reaching the second catch block that means we've failed to report `e` to the debugger. Packaging it in `e2` will ensure it is not lost. --- .../arquillian/protocol/servlet/runner/ServletTestRunner.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/protocols/servlet/src/main/java/org/jboss/arquillian/protocol/servlet/runner/ServletTestRunner.java b/protocols/servlet/src/main/java/org/jboss/arquillian/protocol/servlet/runner/ServletTestRunner.java index 01fd0141b..1bb1d4624 100644 --- a/protocols/servlet/src/main/java/org/jboss/arquillian/protocol/servlet/runner/ServletTestRunner.java +++ b/protocols/servlet/src/main/java/org/jboss/arquillian/protocol/servlet/runner/ServletTestRunner.java @@ -201,7 +201,9 @@ private void writeObject(Object object, HttpServletResponse response) { try { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } catch (Exception e2) { - throw new RuntimeException("Could not write to output", e2); + RuntimeException runtimeException = new RuntimeException("Could not write to output", e2); + runtimeException.addSuppressed(e); + throw runtimeException; } } }