From 2f8dc9e659281da25a6e49aca3937868d49cec04 Mon Sep 17 00:00:00 2001 From: Adrian Sutton Date: Tue, 29 Jan 2019 15:31:45 +1000 Subject: [PATCH] Delegate getRootCause through to Guava's implementation to avoid re-implementing the wheel (keep our wrapper method to preserve null safe handling). --- .../tech/pegasys/pantheon/util/ExceptionUtils.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/util/src/main/java/tech/pegasys/pantheon/util/ExceptionUtils.java b/util/src/main/java/tech/pegasys/pantheon/util/ExceptionUtils.java index 87fcf59325..5dc3ccb79c 100644 --- a/util/src/main/java/tech/pegasys/pantheon/util/ExceptionUtils.java +++ b/util/src/main/java/tech/pegasys/pantheon/util/ExceptionUtils.java @@ -12,6 +12,8 @@ */ package tech.pegasys.pantheon.util; +import com.google.common.base.Throwables; + public class ExceptionUtils { private ExceptionUtils() {} @@ -23,16 +25,6 @@ private ExceptionUtils() {} * @return The root cause */ public static Throwable rootCause(final Throwable throwable) { - Throwable cause = throwable; - - while (cause != null) { - if (cause.getCause() == null) { - break; - } - - cause = cause.getCause(); - } - - return cause; + return throwable != null ? Throwables.getRootCause(throwable) : null; } }