Skip to content

Commit

Permalink
--corrected the isUnchecked method to check for null (#1079)
Browse files Browse the repository at this point in the history
--created test for null case
  • Loading branch information
orionlibs committed Jul 3, 2023
1 parent 6ea4e39 commit f68a643
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ public static boolean isChecked(final Throwable throwable) {
* @since 3.13.0
*/
public static boolean isUnchecked(final Throwable throwable) {
return !isChecked(throwable);
return throwable != null && (throwable instanceof Error || throwable instanceof RuntimeException);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,11 @@ public void testIsCheckedCustomThrowable() {
assertTrue(ExceptionUtils.isChecked(new TestThrowable()));
}

@Test
public void testIsUnchecked_null() {
assertFalse(ExceptionUtils.isUnchecked(null));
}

@Test
public void testIsUnchecked_checked() {
assertFalse(ExceptionUtils.isUnchecked(new IOException()));
Expand Down

0 comments on commit f68a643

Please sign in to comment.