--corrected the isUnchecked method to check for null (#1079)
--created test for null case
This commit is contained in:
parent
6ea4e39087
commit
f68a643ef9
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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()));
|
||||
|
|
Loading…
Reference in New Issue