File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
vavr/src/main/java/io/vavr/control Expand file tree Collapse file tree 1 file changed +18
-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
@@ -1706,4 +1706,21 @@ static <T extends Throwable, R> R sneakyThrow(Throwable t) throws T {
17061706 throw (T ) t ;
17071707 }
17081708
1709+ static class ThreadDeathResolver {
1710+ static final Class <?> THREAD_DEATH_CLASS = resolve ();
1711+
1712+ static boolean isThreadDeath (Throwable throwable ) {
1713+ return THREAD_DEATH_CLASS != null && THREAD_DEATH_CLASS .isInstance (throwable );
1714+ }
1715+
1716+ private static Class <?> resolve () {
1717+ try {
1718+ return Class .forName ("java.lang.ThreadDeath" );
1719+ } catch (ClassNotFoundException e ) {
1720+ return null ;
1721+ }
1722+ }
1723+ }
17091724}
1725+
1726+
You can’t perform that action at this time.
0 commit comments