--corrected the isUnchecked method to check for null (#1079)

--created test for null case
This commit is contained in:
Dimitrios Efthymiou 2023-07-03 11:58:45 +01:00 committed by GitHub
parent 6ea4e39087
commit f68a643ef9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -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);
}
/**

View File

@ -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()));