From 9ee08bdce2b17d74e694571973afbea52275000f Mon Sep 17 00:00:00 2001 From: Foivos Zakkak Date: Thu, 10 Oct 2024 14:48:37 +0300 Subject: [PATCH] Avoid recursive printing of exception causes `printStackTrace` already recursively prints the causes --- .../com/oracle/svm/hosted/NativeImageGeneratorRunner.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGeneratorRunner.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGeneratorRunner.java index f2769768975f..7598c09d52d5 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGeneratorRunner.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGeneratorRunner.java @@ -714,11 +714,10 @@ private static void reportUserException(Throwable e, OptionValues parsedHostedOp } else { reportUserError(e.getMessage()); } - Throwable current = e.getCause(); - while (current != null) { + Throwable cause = e.getCause(); + if (cause != null) { System.out.print("Caused by: "); - current.printStackTrace(System.out); - current = current.getCause(); + cause.printStackTrace(System.out); } if (parsedHostedOptions != null && NativeImageOptions.ReportExceptionStackTraces.getValue(parsedHostedOptions)) { System.out.print("Internal exception: ");