This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-lang.git
The following commit(s) were added to refs/heads/master by this push: new f68a643ef --corrected the isUnchecked method to check for null (#1079) f68a643ef is described below commit f68a643ef99189d10a6753167367dcc8f943d634 Author: Dimitrios Efthymiou <efthymiou.dimitri...@gmail.com> AuthorDate: Mon Jul 3 11:58:45 2023 +0100 --corrected the isUnchecked method to check for null (#1079) --created test for null case --- src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java | 2 +- .../java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java b/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java index c98b5ed36..d1460b81f 100644 --- a/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java +++ b/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java @@ -641,7 +641,7 @@ public class ExceptionUtils { * @since 3.13.0 */ public static boolean isUnchecked(final Throwable throwable) { - return !isChecked(throwable); + return throwable != null && (throwable instanceof Error || throwable instanceof RuntimeException); } /** diff --git a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java index 956a72390..c103345ff 100644 --- a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java @@ -635,6 +635,11 @@ public class ExceptionUtilsTest extends AbstractLangTest { assertTrue(ExceptionUtils.isChecked(new TestThrowable())); } + @Test + public void testIsUnchecked_null() { + assertFalse(ExceptionUtils.isUnchecked(null)); + } + @Test public void testIsUnchecked_checked() { assertFalse(ExceptionUtils.isUnchecked(new IOException()));