From 401b800a8c9988d4d3e75be6e55f7cd556943c8f Mon Sep 17 00:00:00 2001 From: lgc <649010454@qq.com> Date: Fri, 28 Apr 2023 16:38:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E4=BD=BF=E7=94=A8Apache-Commons-Lang3?= =?UTF-8?q?=E7=9A=84=E8=8E=B7=E5=8F=96=E6=9C=80=E5=B0=BE=E7=AB=AF=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=EF=BC=8C=E9=87=87=E7=94=A8=E9=80=92=E5=BD=92=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dromara/hutool/core/exception/ExceptionUtil.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hutool-core/src/main/java/org/dromara/hutool/core/exception/ExceptionUtil.java b/hutool-core/src/main/java/org/dromara/hutool/core/exception/ExceptionUtil.java index ae5da1aa7..01fbc5bd5 100644 --- a/hutool-core/src/main/java/org/dromara/hutool/core/exception/ExceptionUtil.java +++ b/hutool-core/src/main/java/org/dromara/hutool/core/exception/ExceptionUtil.java @@ -416,16 +416,17 @@ public class ExceptionUtil { * 此方法通过调用{@link Throwable#getCause()} 直到没有cause为止,如果异常本身没有cause,返回异常本身
* 传入null返回也为null * - *

- * 此方法来自Apache-Commons-Lang3 - *

* * @param throwable 异常对象,可能为null * @return 最尾端异常,传入null参数返回也为null */ public static Throwable getRootCause(final Throwable throwable) { - final List list = getThrowableList(throwable); - return list.size() < 1 ? null : list.get(list.size() - 1); + Throwable cause = throwable.getCause(); + if (cause != null) { + return getRootCause(cause); + }else{ + return throwable; + } } /**