File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
src/main/java/io/vavr/control Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -1848,7 +1848,7 @@ interface TryModule {
18481848 static boolean isFatal (Throwable throwable ) {
18491849 return throwable instanceof InterruptedException
18501850 || throwable instanceof LinkageError
1851- || throwable instanceof ThreadDeath
1851+ || ThreadDeathChecker . isThreadDeath ( throwable )
18521852 || throwable instanceof VirtualMachineError ;
18531853 }
18541854
@@ -1858,4 +1858,19 @@ static <T extends Throwable, R> R sneakyThrow(Throwable t) throws T {
18581858 throw (T ) t ;
18591859 }
18601860
1861+ class ThreadDeathChecker {
1862+ static final Class <?> THREAD_DEATH_CLASS = resolve ();
1863+
1864+ static boolean isThreadDeath (Throwable throwable ) {
1865+ return THREAD_DEATH_CLASS != null && THREAD_DEATH_CLASS .isInstance (throwable );
1866+ }
1867+
1868+ private static Class <?> resolve () {
1869+ try {
1870+ return Class .forName ("java.lang.ThreadDeath" );
1871+ } catch (ClassNotFoundException e ) {
1872+ return null ;
1873+ }
1874+ }
1875+ }
18611876}
You can’t perform that action at this time.
0 commit comments