Skip to content

Commit 62922fe

Browse files
committed
svm: adopt "JDK-8288899 java/util/concurrent/ExecutorService/CloseTest.java failed with "InterruptedException: sleep interrupted""
1 parent 95b03ba commit 62922fe

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/DeferredCommonPool.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
3535
import java.util.concurrent.TimeUnit;
3636
import java.util.concurrent.TimeoutException;
3737

38+
import com.oracle.svm.core.util.VMError;
39+
import com.oracle.svm.util.ReflectionUtil;
40+
41+
import jdk.graal.compiler.serviceprovider.JavaVersionUtil;
42+
3843
/**
3944
* Pure delegate implementation to ForkJoinPool.commonPool().
4045
*/
@@ -79,9 +84,29 @@ public ForkJoinTask<?> submit(Runnable task) {
7984
return ForkJoinPool.commonPool().submit(task);
8085
}
8186

87+
@SuppressWarnings("unchecked")
88+
public <T> List<Future<T>> invokeAllUninterruptibly(Collection<? extends Callable<T>> tasks) {
89+
VMError.guarantee(JavaVersionUtil.JAVA_SPEC >= 22, "invokeAllUninterruptibly only exits in JDK 22+");
90+
var m = ReflectionUtil.lookupMethod(ForkJoinPool.class, "invokeAllUninterruptibly", Collection.class);
91+
try {
92+
return (List<Future<T>>) m.invoke(ForkJoinPool.commonPool(), tasks);
93+
} catch (ReflectiveOperationException e) {
94+
throw VMError.shouldNotReachHere(e);
95+
}
96+
}
97+
8298
@Override
8399
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) {
84-
return ForkJoinPool.commonPool().invokeAll(tasks);
100+
try {
101+
return ForkJoinPool.commonPool().invokeAll(tasks);
102+
} catch (Throwable ex) {
103+
throw rethrow(ex);
104+
}
105+
}
106+
107+
@SuppressWarnings({"unchecked"})
108+
private static <E extends Throwable> RuntimeException rethrow(Throwable ex) throws E {
109+
throw (E) ex;
85110
}
86111

87112
@Override

0 commit comments

Comments
 (0)