From 571d600b09d231ec4d733e068ba8f1b386b021c4 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Mon, 2 Dec 2024 02:31:04 +0100 Subject: [PATCH] Fix NPE in stacktraceAsStringRecursive method --- .../engine/base/utility/misc/Miscellaneous.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/base/src/main/java/de/staropensource/engine/base/utility/misc/Miscellaneous.java b/base/src/main/java/de/staropensource/engine/base/utility/misc/Miscellaneous.java index af5b5f3..5fe8394 100644 --- a/base/src/main/java/de/staropensource/engine/base/utility/misc/Miscellaneous.java +++ b/base/src/main/java/de/staropensource/engine/base/utility/misc/Miscellaneous.java @@ -193,15 +193,15 @@ public final class Miscellaneous { output .append("\n") .append(stacktraceAsStringRecursive(throwable.getCause(), indent, includeHeader)); - if (throwable instanceof ClassNotFoundException exception) + if (throwable instanceof ClassNotFoundException exception && exception.getException() != null) output .append("\n") .append(stacktraceAsStringRecursive(exception.getException(), indent, includeHeader)); - if (throwable instanceof ExceptionInInitializerError exception) + if (throwable instanceof ExceptionInInitializerError exception && exception.getException() != null) output .append("\n") .append(stacktraceAsStringRecursive(exception.getException(), indent, includeHeader)); - if (throwable instanceof InvocationTargetException exception) + if (throwable instanceof InvocationTargetException exception && exception.getTargetException() != null) output .append("\n") .append(stacktraceAsStringRecursive(exception.getTargetException(), indent, includeHeader));