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 {
1696
1696
static boolean isFatal (Throwable throwable ) {
1697
1697
return throwable instanceof InterruptedException
1698
1698
|| throwable instanceof LinkageError
1699
- || throwable instanceof ThreadDeath
1699
+ || ThreadDeathResolver . isThreadDeath ( throwable )
1700
1700
|| throwable instanceof VirtualMachineError ;
1701
1701
}
1702
1702
@@ -1706,4 +1706,21 @@ static <T extends Throwable, R> R sneakyThrow(Throwable t) throws T {
1706
1706
throw (T ) t ;
1707
1707
}
1708
1708
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
+ }
1709
1724
}
1725
+
1726
+
You can’t perform that action at this time.
0 commit comments