fix NPE in DefaultLogger.attachmentsToString

This commit is contained in:
peter
2016-05-11 16:58:28 +02:00
parent f58d9f5144
commit 956a51036d
2 changed files with 4 additions and 3 deletions
@@ -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<Attachment, String>() {
@@ -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();