From 956a51036d2a5a87f6fbe3c4a81cca18df362405 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 11 May 2016 16:57:45 +0200 Subject: [PATCH] fix NPE in DefaultLogger.attachmentsToString --- .../src/com/intellij/openapi/diagnostic/DefaultLogger.java | 4 ++-- platform/util/src/com/intellij/util/ExceptionUtil.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/platform/util/src/com/intellij/openapi/diagnostic/DefaultLogger.java b/platform/util/src/com/intellij/openapi/diagnostic/DefaultLogger.java index 16b1360a7cfa..0943a0775ae1 100644 --- a/platform/util/src/com/intellij/openapi/diagnostic/DefaultLogger.java +++ b/platform/util/src/com/intellij/openapi/diagnostic/DefaultLogger.java @@ -77,9 +77,9 @@ public class DefaultLogger extends Logger { @Override public void setLevel(Level level) { } - public static String attachmentsToString(Throwable t) { + public static String attachmentsToString(@Nullable Throwable t) { //noinspection ThrowableResultOfMethodCallIgnored - Throwable rootCause = ExceptionUtil.getRootCause(t); + Throwable rootCause = t == null ? null : ExceptionUtil.getRootCause(t); if (rootCause instanceof ExceptionWithAttachments) { return "\nAttachments:" + StringUtil.join(((ExceptionWithAttachments)rootCause).getAttachments(), new Function() { diff --git a/platform/util/src/com/intellij/util/ExceptionUtil.java b/platform/util/src/com/intellij/util/ExceptionUtil.java index 0f4491b04f3f..1fc03c880992 100644 --- a/platform/util/src/com/intellij/util/ExceptionUtil.java +++ b/platform/util/src/com/intellij/util/ExceptionUtil.java @@ -27,7 +27,8 @@ import java.util.Arrays; public class ExceptionUtil { private ExceptionUtil() { } - public static Throwable getRootCause(Throwable e) { + @NotNull + public static Throwable getRootCause(@NotNull Throwable e) { while (true) { if (e.getCause() == null) return e; e = e.getCause();