File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
vavr/src/main/java/io/vavr/control Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -1696,7 +1696,7 @@ interface TryModule {
16961696 static boolean isFatal (Throwable throwable ) {
16971697 return throwable instanceof InterruptedException
16981698 || throwable instanceof LinkageError
1699- || throwable instanceof ThreadDeath
1699+ || ThreadDeathResolver . isThreadDeath ( throwable )
17001700 || throwable instanceof VirtualMachineError ;
17011701 }
17021702
@@ -1707,3 +1707,19 @@ static <T extends Throwable, R> R sneakyThrow(Throwable t) throws T {
17071707 }
17081708
17091709}
1710+
1711+ static class ThreadDeathResolver {
1712+ static final Class <?> THREAD_DEATH_CLASS = resolve ();
1713+
1714+ static boolean isThreadDeath (Throwable throwable ) {
1715+ return THREAD_DEATH_CLASS != null && THREAD_DEATH_CLASS .isInstance (throwable );
1716+ }
1717+
1718+ private static Class <?> resolve () {
1719+ try {
1720+ return Class .forName ("java.lang.ThreadDeath" );
1721+ } catch (ClassNotFoundException e ) {
1722+ return null ;
1723+ }
1724+ }
1725+ }
You can’t perform that action at this time.
0 commit comments