JDK-8288899 : java/util/concurrent/ExecutorService/CloseTest.java failed with "InterruptedException: sleep interrupted"
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.concurrent
  • Affected Version: 19,20
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: os_x
  • CPU: aarch64
  • Submitted: 2022-06-21
  • Updated: 2024-06-24
  • Resolved: 2023-10-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 22
22 b22Fixed
Related Reports
CSR :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Sub Tasks
JDK-8298976 :  
JDK-8318145 :  
Description
The following test failed in the JDK19 CI:

java/util/concurrent/ExecutorService/CloseTest.java

Here's a snippet from the log file:

#section:testng
----------messages:(4/187)----------
command: testng --enable-preview CloseTest
reason: User specified action: run testng/othervm --enable-preview CloseTest 
Mode: othervm [/othervm specified]
elapsed time (seconds): 15.006
----------configuration:(0/0)----------
----------System.out:(96/7646)----------
test CloseTest.testCloseWithNoTasks(DelegatingExecutorService@7b7f3bb0): success
test CloseTest.testCloseWithNoTasks(java.util.concurrent.ForkJoinPool@1e49cee): success
test CloseTest.testCloseWithNoTasks(java.util.concurrent.ThreadPoolExecutor@ab34110): success
test CloseTest.testCloseWithNoTasks(java.util.concurrent.ThreadPoolExecutor@3f6bb975): success
test CloseTest.testCloseWithNoTasks(java.util.concurrent.ThreadPerTaskExecutor@2374acc): success
test CloseTest.testCloseWithNoTasks(java.util.concurrent.ThreadPerTaskExecutor@7d01fd): success
test CloseTest.testCloseWithRunningTasks(DelegatingExecutorService@43b6459b): success
test CloseTest.testCloseWithRunningTasks(java.util.concurrent.ForkJoinPool@4ca68453): success
test CloseTest.testCloseWithRunningTasks(java.util.concurrent.ThreadPoolExecutor@7e3325a9): success
test CloseTest.testCloseWithRunningTasks(java.util.concurrent.ThreadPoolExecutor@4229df43): success
test CloseTest.testCloseWithRunningTasks(java.util.concurrent.ThreadPerTaskExecutor@30bb95a0): success
test CloseTest.testCloseWithRunningTasks(java.util.concurrent.ThreadPerTaskExecutor@1c79a0bb): success
test CloseTest.testInterruptBeforeClose(DelegatingExecutorService@7a49883e): success
test CloseTest.testInterruptBeforeClose(java.util.concurrent.ForkJoinPool@5b5901f5): success
test CloseTest.testInterruptBeforeClose(java.util.concurrent.ThreadPoolExecutor@20683f1f): success
test CloseTest.testInterruptBeforeClose(java.util.concurrent.ThreadPoolExecutor@2466d7a0): success
test CloseTest.testInterruptBeforeClose(java.util.concurrent.ThreadPerTaskExecutor@1251a689): success
test CloseTest.testInterruptBeforeClose(java.util.concurrent.ThreadPerTaskExecutor@7a9505c1): success
test CloseTest.testInterruptDuringClose(DelegatingExecutorService@3d2f87c8): success
test CloseTest.testInterruptDuringClose(java.util.concurrent.ForkJoinPool@1f031981): success
test CloseTest.testInterruptDuringClose(java.util.concurrent.ThreadPoolExecutor@586ab76b): success
test CloseTest.testInterruptDuringClose(java.util.concurrent.ThreadPoolExecutor@7bf7f12f): success
test CloseTest.testInterruptDuringClose(java.util.concurrent.ThreadPerTaskExecutor@26a4d6db): success
test CloseTest.testInterruptDuringClose(java.util.concurrent.ThreadPerTaskExecutor@3546b953): success
test CloseTest.testShutdownBeforeClose(DelegatingExecutorService@29ba3d8b): success
test CloseTest.testShutdownBeforeClose(java.util.concurrent.ForkJoinPool@78e55947): failure
java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.InterruptedException: sleep interrupted
	at java.base/java.util.concurrent.ForkJoinTask.reportExecutionException(ForkJoinTask.java:581)
	at java.base/java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:993)
	at CloseTest.testShutdownBeforeClose(CloseTest.java:113)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:578)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:132)
	at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:599)
	at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:174)
	at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
	at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:822)
	at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:147)
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at org.testng.TestRunner.privateRun(TestRunner.java:764)
	at org.testng.TestRunner.run(TestRunner.java:585)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:384)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337)
	at org.testng.SuiteRunner.run(SuiteRunner.java:286)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1218)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
	at org.testng.TestNG.runSuites(TestNG.java:1069)
	at org.testng.TestNG.run(TestNG.java:1037)
	at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:94)
	at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:54)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:578)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
	at java.base/java.lang.Thread.run(Thread.java:1596)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.InterruptedException: sleep interrupted
	at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:484)
	at java.base/java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:540)
	at java.base/java.util.concurrent.ForkJoinTask.reportExecutionException(ForkJoinTask.java:580)
	... 31 more
Caused by: java.lang.RuntimeException: java.lang.InterruptedException: sleep interrupted
	at java.base/java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1461)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1311)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1840)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1806)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
Caused by: java.lang.InterruptedException: sleep interrupted
	at java.base/java.lang.Thread.sleep0(Native Method)
	at java.base/java.lang.Thread.sleep(Thread.java:465)
	at java.base/java.lang.Thread.sleep(Thread.java:547)
	at CloseTest.lambda$testShutdownBeforeClose$1(CloseTest.java:102)
	at java.base/java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1456)
	... 5 more
test CloseTest.testShutdownBeforeClose(java.util.concurrent.ThreadPoolExecutor@5a48cbe6): success
test CloseTest.testShutdownBeforeClose(java.util.concurrent.ThreadPoolExecutor@351f851c): success
test CloseTest.testShutdownBeforeClose(java.util.concurrent.ThreadPerTaskExecutor@33f236a5): success
test CloseTest.testShutdownBeforeClose(java.util.concurrent.ThreadPerTaskExecutor@3805b133): success
test CloseTest.testTerminateBeforeClose(DelegatingExecutorService@1453fbfb): success
test CloseTest.testTerminateBeforeClose(java.util.concurrent.ForkJoinPool@6d182c98): success
test CloseTest.testTerminateBeforeClose(java.util.concurrent.ThreadPoolExecutor@5f0d59b): success
test CloseTest.testTerminateBeforeClose(java.util.concurrent.ThreadPoolExecutor@770623e3): success
test CloseTest.testTerminateBeforeClose(java.util.concurrent.ThreadPerTaskExecutor@122fcfb5): success
test CloseTest.testTerminateBeforeClose(java.util.concurrent.ThreadPerTaskExecutor@24b9a354): success

===============================================
java/util/concurrent/ExecutorService/CloseTest.java
Total tests run: 36, Passes: 35, Failures: 1, Skips: 0
===============================================

----------System.err:(12/672)----------
java.lang.Exception: failures: 1
	at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:96)
	at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:54)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:578)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
	at java.base/java.lang.Thread.run(Thread.java:1596)

JavaTest Message: Test threw exception: java.lang.Exception: failures: 1
JavaTest Message: shutting down test

STATUS:Failed.`main' threw exception: java.lang.Exception: failures: 1
----------rerun:(35/6831)*----------
Comments
There was a merge error when this chage gets into the repository, where two test cases were inadvertently re-added to ProblemList.txt. JDK-8334810 will address it
24-06-2024

This change is now causing actual JCK test failures e.g java.lang.AssertionError: javasoft.sqe.tests.api.java.util.concurrent.ForkJoinPool19Test@74ec20b5: interrupt status set in main thread at javasoft.sqe.tests.api.java.util.concurrent.JSR166TestCase.tearDownFail(JSR166TestCase.java:342) at javasoft.sqe.tests.api.java.util.concurrent.JSR166TestCase.tearDown(JSR166TestCase.java:368) at javasoft.sqe.tests.api.junit.TestCase.invokeTestCase(TestCase.java:53) at javasoft.sqe.javatest.lib.MultiTest.run(MultiTest.java:195) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) and Expected exception java.lang.RuntimeException was not thrown by testcase "testAdaptInterruptibleException" "java.io.IOException: java.io.IOException" was thrown instead java.io.IOException: java.io.IOException at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486) at java.base/java.util.concurrent.ForkJoinTask.getException(ForkJoinTask.java:555) at java.base/java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:573) at java.base/java.util.concurrent.ForkJoinTask.join(ForkJoinTask.java:663) at java.base/java.util.concurrent.ForkJoinPool.invoke(ForkJoinPool.java:3102) at javasoft.sqe.tests.api.java.util.concurrent.ForkJoinTask.AdaptInterruptibleTests.testAdaptInterruptibleException(AdaptInterruptibleTests.java:81) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) ... Caused by: java.io.IOException at javasoft.sqe.tests.api.java.util.concurrent.ForkJoinTask.AdaptInterruptibleTests.lambda$testAdaptInterruptibleException$1(AdaptInterruptibleTests.java:79) at java.base/java.util.concurrent.ForkJoinTask$AdaptedInterruptibleCallable.compute(ForkJoinTask.java:1689) at java.base/java.util.concurrent.ForkJoinTask$InterruptibleTask.exec(ForkJoinTask.java:1641) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1486) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:2077) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2028) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187)
06-11-2023

The test is essentially pool.invoke(adaptInterruptible(Callable)) where the Callable task throws a checked exception. The invoke(ForkJoinTask) method doesn't specify how it handles checked exceptions, previous behavior was to wrap it with a runtime exception, which is what the test expects. I've created JDK-8319498 to track this.
06-11-2023

The PR includes test updates about expecting interrupts in different cases -- for the JSR166TestCase versions in openjdk/jdk/test/jdk/java/util/concurrent. Should they also be updated elsewhere for sake of standalone JCK?
06-11-2023

Changeset: 667cca9d Author: Doug Lea <dl@openjdk.org> Date: 2023-10-27 10:08:59 +0000 URL: https://git.openjdk.org/jdk/commit/667cca9d7aef1ff4abe630cefaac34c0b1646925
27-10-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/14301 Date: 2023-06-03 14:08:02 +0000
05-06-2023

This small-looking problem required a large-looking solution. Not only was it possible for some tasks submitted under ExecutorService specs not to be cancelled on close, but internal data structures had been allowed to become inconsistent during shutdown (because it doesn't matter for the computational tasks initially targeted by this class. See the PR for more details.
03-06-2023

[~dl], The way I run this test is - I've removed all the jtreg related details from the https://github.com/openjdk/jdk/blob/master/test/jdk/java/util/concurrent/ExecutorService/CloseTest.java and turned it in to a trivial Java program (which essentially is same as what that jtreg test does). The java program is as follows: import java.util.concurrent.*; import java.time.*; public class Test { public static void main(final String[] args) throws Exception { final ForkJoinPool executor = new ForkJoinPool(); testShutdownBeforeClose(executor); System.out.println("Completed successfully"); } private static void testShutdownBeforeClose(final ExecutorService executor) throws Exception { Phaser phaser = new Phaser(2); Future<?> future = executor.submit(() -> { phaser.arriveAndAwaitAdvance(); Thread.sleep(Duration.ofMillis(100)); return "foo"; }); phaser.arriveAndAwaitAdvance(); // wait for task to start executor.shutdown(); // shutdown, will not immediately terminate executor.close(); assertTrue(executor.isShutdown()); assertTrue(executor.isTerminated()); assertTrue(executor.awaitTermination(10, TimeUnit.MILLISECONDS)); final var r = future.get(); if (!"foo".equals(r)) { throw new RuntimeException("incorrect result " + r); } } private static void assertTrue(boolean b) { if (!b) { throw new RuntimeException("Assertion Failed"); } } } I then have a bash script which repeatedly launches this Java program until the program exits with a failure. The contents of the test.sh script is as follows: i=0; until ! ${JAVA_HOME}/bin/java -XshowSettings Test.java 1>out.log 2>err.log; do echo $i > status.txt; i=$((i+1)); done; I launch it as: nohup bash ./test.sh & I let it run till it fails or runs for at least a few days. So far, on a macos aarch64 setup, this program keeps failing after around 30k or 40k runs with the exception stacktrace (that will be available in generated err.log file) noted above.
10-01-2023

Hello Doug [~dl], with the latest changes in that branch, the issue noted in this JBS still continue to be present. My test run failed with the following exception stacktrace: Exception in thread "main" java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.InterruptedException: sleep interrupted at java.base/java.util.concurrent.ForkJoinTask.reportExecutionException(ForkJoinTask.java:584) at java.base/java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:997) at Test.testShutdownBeforeClose(Test.java:26) at Test.main(Test.java:7) Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.InterruptedException: sleep interrupted at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:484) at java.base/java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:543) at java.base/java.util.concurrent.ForkJoinTask.reportExecutionException(ForkJoinTask.java:583) at java.base/java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:997) at Test.testShutdownBeforeClose(Test.java:26) at Test.main(Test.java:7) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:578) at jdk.compiler/com.sun.tools.javac.launcher.Main.execute(Main.java:435) at jdk.compiler/com.sun.tools.javac.launcher.Main.run(Main.java:205) at jdk.compiler/com.sun.tools.javac.launcher.Main.main(Main.java:132) Caused by: java.lang.RuntimeException: java.lang.InterruptedException: sleep interrupted at java.base/java.util.concurrent.ForkJoinTask$AdaptedInterruptibleCallable.exec(ForkJoinTask.java:1513) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1328) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1862) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1827) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188) Caused by: java.lang.InterruptedException: sleep interrupted at java.base/java.lang.Thread.sleep0(Native Method) at java.base/java.lang.Thread.sleep(Thread.java:484) at java.base/java.lang.Thread.sleep(Thread.java:566) at Test.lambda$testShutdownBeforeClose$0(Test.java:15) at java.base/java.util.concurrent.ForkJoinTask$AdaptedInterruptibleCallable.exec(ForkJoinTask.java:1508) ... 5 more
10-01-2023

Hello Doug [~dl], I've triggered a fresh round of tests against your latest commits in that branch. I should have the early results tomorrow and once those are done, I will run an extended test (which could take a day or more to complete) to try to reproduce the issue noted in this JBS. I'll update this issue once those runs are done.
09-01-2023

The new version (at https://github.com/DougLea/jdk/tree/JDK-8288899) covers another exception incompatibility. Could someone recheck tests?
07-01-2023

Thanks. A new update should fix the remaining problems. These were due to mismatches about which exceptions to prefer or report for ExecutorService methods (that differ from default FJ tasks). Could you recheck?
05-01-2023

In addition to the "InterruptedException: sleep interrupted" failure in this above test, with the latest changes in that branch, I also ran into a failure in the java/util/concurrent/tck/JSR166TestCase.java test case. This failed on a linux-aarch64 machine and the exception stacktrace is as follows (unfortunately, it isn't the complete stacktrace because jtreg limited it after the log messages exceeding a limit): java.util.concurrent.CancellationException at java.base/java.util.concurrent.ForkJoinTask.uncheckedThrow(ForkJoinTask.java:604) at java.base/java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:569) at java.base/java.util.concurrent.ForkJoinTask.invokeAll(ForkJoinTask.java:708) at RecursiveActionTest$FibAction.realCompute(RecursiveActionTest.java:212) at JSR166TestCase$CheckedRecursiveAction.compute(JSR166TestCase.java:1919) at java.base/java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:194) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387) at java.base/java.util.concurrent.ForkJoinTask.invokeAll(ForkJoinTask.java:698) at RecursiveActionTest$FibAction.realCompute(RecursiveActionTest.java:212) at JSR166TestCase$CheckedRecursiveAction.compute(JSR166TestCase.java:1919) at java.base/java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:194) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1325) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1861) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1825) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188) java.util.concurrent.CancellationException java.util.concurrent.CancellationException at java.base/java.util.concurrent.ForkJoinTask.uncheckedThrow(ForkJoinTask.java:604) at java.base/java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:569) at java.base/java.util.concurrent.ForkJoinTask.invokeAll(ForkJoinTask.java:708) at RecursiveActionTest$FibAction.realCompute(RecursiveActionTest.java:212) at JSR166TestCase$CheckedRecursiveAction.compute(JSR166TestCase.java:1919) at java.base/java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:194) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387) at java.base/java.util.concurrent.ForkJoinTask.invokeAll(ForkJoinTask.java:698) at RecursiveActionTest$FibAction.realCompute(RecursiveActionTest.java:212) at JSR166TestCase$CheckedRecursiveAction.compute(JSR166TestCase.java:1919) at java.base/java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:194) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1325) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1861) at java.base/java.util.concurrent.ForkJoinPool.runWo
05-01-2023

Hello Doug [~dl], like Alan, I have been running similar tests with your latest https://github.com/DougLea/jdk/commits/JDK-8288899 branch. With these latest changes, I still see that the "InterruptedException: sleep interrupted" failures on a macos aarch64 VM. The stacktrace is as follows: Exception in thread "main" java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.InterruptedException: sleep interrupted at java.base/java.util.concurrent.ForkJoinTask.reportExecutionException(ForkJoinTask.java:583) at java.base/java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:996) at Test.testShutdownBeforeClose(Test.java:26) at Test.main(Test.java:7) Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.InterruptedException: sleep interrupted at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:484) at java.base/java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:542) at java.base/java.util.concurrent.ForkJoinTask.reportExecutionException(ForkJoinTask.java:582) at java.base/java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:996) at Test.testShutdownBeforeClose(Test.java:26) at Test.main(Test.java:7) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:578) at jdk.compiler/com.sun.tools.javac.launcher.Main.execute(Main.java:435) at jdk.compiler/com.sun.tools.javac.launcher.Main.run(Main.java:205) at jdk.compiler/com.sun.tools.javac.launcher.Main.main(Main.java:132) Caused by: java.lang.RuntimeException: java.lang.InterruptedException: sleep interrupted at java.base/java.util.concurrent.ForkJoinTask$AdaptedInterruptibleCallable.exec(ForkJoinTask.java:1500) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1325) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1861) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1825) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188) Caused by: java.lang.InterruptedException: sleep interrupted at java.base/java.lang.Thread.sleep0(Native Method) at java.base/java.lang.Thread.sleep(Thread.java:484) at java.base/java.lang.Thread.sleep(Thread.java:566) at Test.lambda$testShutdownBeforeClose$0(Test.java:15) at java.base/java.util.concurrent.ForkJoinTask$AdaptedInterruptibleCallable.exec(ForkJoinTask.java:1495) ... 5 more The standalone Java code that reproduces this above issue is as follows (I've even attached it as a Test.java file to this issue). This code is same as what the jtreg tests does, except that this one doesn't rely on any jtreg infrastructure to run: import java.util.concurrent.*; import java.time.*; public class Test { public static void main(final String[] args) throws Exception { final ForkJoinPool executor = new ForkJoinPool(); testShutdownBeforeClose(executor); System.out.println("Completed successfully"); } private static void testShutdownBeforeClose(final ExecutorService executor) throws Exception { Phaser phaser = new Phaser(2); Future<?> future = executor.submit(() -> { phaser.arriveAndAwaitAdvance(); Thread.sleep(Duration.ofMillis(100)); return "foo"; }); phaser.arriveAndAwaitAdvance(); // wait for task to start executor.shutdown(); // shutdown, will not immediately terminate executor.close(); assertTrue(executor.isShutdown()); assertTrue(executor.isTerminated()); assertTrue(executor.awaitTermination(10, TimeUnit.MILLISECONDS)); final var r = future.get(); if (!"foo".equals(r)) { throw new RuntimeException("incorrect result " + r); } } private static void assertTrue(boolean b) { if (!b) { throw new RuntimeException("Assertion Failed"); } } } The macos aarch64 VM is currently on: $> sw_vers ProductName: macOS ProductVersion: 12.3.1 BuildVersion: 21E258
05-01-2023

I tried the update with release + debug builds of all platforms, 2000 runs per build. No failures with AsyncShutdown, ExecutorService/Close. Good!
02-01-2023

The problem was that after an interrupted cancellation, a worker might run another without interrupt set when racing against other cancellations during termination. An update now uniformly corrects for this across ExecutorService methods and adds some explanation.(for non-interruptible FJ tasks, this has never mattered).
01-01-2023

I did some initial testing with the change on all platforms with both release and debug builds. Jai is doing more extensive test runs. For the initial testing, 1000 runs per build, AsyncShutdownNow.invokeAll timed out (hung) in 5 runs (2 windows-x64, 1 windows-x64-debug, and 2 linux-aarch64-debug). In all 5 cases, the main thread is blocked in quietlyJoin and there is one worker blocked indefinitely in sleep. The invokeAll test runs two tasks, only one appears to have been cancelled/interrupted. Here's the stack trace of both the main thread and the remaining worker. "AgentVMThread" #138 [9492] prio=5 os_prio=0 cpu=31.25ms elapsed=487.83s allocated=730K defined_classes=30 tid=0x000001d37f6847b0 nid=9492 waiting on condition [0x0000008fa8afd000] java.lang.Thread.State: WAITING (parking) at jdk.internal.misc.Unsafe.park(java.base@21-internal/Native Method) - parking to wait for <0x00000000d01395e0> (a java.util.concurrent.ForkJoinTask$AdaptedInterruptibleCallable) at java.util.concurrent.locks.LockSupport.park(java.base@21-internal/LockSupport.java:371) at java.util.concurrent.ForkJoinTask.awaitDone(java.base@21-internal/ForkJoinTask.java:461) at java.util.concurrent.ForkJoinTask.quietlyJoin(java.base@21-internal/ForkJoinTask.java:1035) at java.util.concurrent.ForkJoinPool.invokeAll(java.base@21-internal/ForkJoinPool.java:3012) at AsyncShutdownNow.testInvokeAll(AsyncShutdownNow.java:115) "ForkJoinPool-3-worker-1" #144 [35548] daemon prio=5 os_prio=0 cpu=15.63ms elapsed=487.76s allocated=272B defined_classes=0 tid=0x000001d37f6857a0 nid=35548 waiting on condition [0x0000008fa90fe000] java.lang.Thread.State: TIMED_WAITING (sleeping) at java.lang.Thread.sleep0(java.base@21-internal/Native Method) at java.lang.Thread.sleep(java.base@21-internal/Thread.java:484) at AsyncShutdownNow.lambda$static$0(AsyncShutdownNow.java:51) at AsyncShutdownNow$$Lambda$171/0x0000000100192220.call(Unknown Source) at java.util.concurrent.ForkJoinTask$AdaptedInterruptibleCallable.exec(java.base@21-internal/ForkJoinTask.java:1490) at java.util.concurrent.ForkJoinTask.doExec(java.base@21-internal/ForkJoinTask.java:387) at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(java.base@21-internal/ForkJoinPool.java:1312) at java.util.concurrent.ForkJoinPool.scan(java.base@21-internal/ForkJoinPool.java:1845) at java.util.concurrent.ForkJoinPool.runWorker(java.base@21-internal/ForkJoinPool.java:1811) at java.util.concurrent.ForkJoinWorkerThread.run(java.base@21-internal/ForkJoinWorkerThread.java:188)
29-12-2022

Thanks. These are now failing on invokeAll, which needs changes along the lines of invokeAny. Will do.
29-12-2022

Well, now they seem to be there (I also just committed a cleanup of this change). Sorry for problems.
28-12-2022

[~dl] Are you sure that DougLea/jdk/tree/JDK-8288899 has the commit? The master and JDK-8288899 branch seems to be the same.
28-12-2022

Updates are now at https://github.com/DougLea/jdk/tree/JDK-8288899 . These have passed over a million test runs on x86 machines I have, but it would be helpful if someone could check them on others before issuing PR.
24-12-2022

Hello Doug [~dl], I've triggered some repeated runs on various systems against the branch you linked to. I'll update this issue once those runs complete.
24-12-2022

OK, given the constraints, I'm back to thinking that just allowing lockup is fine.
19-12-2022

The default implementation of close wouldn't be able to throw an exception as it is implemented with shutdown + awaitTermination. However, the method could be specified to throw on a best effort basis. WrongThreadException is a possible candidate, another is IllegalCallerException if call from a running task. An exception would be better than deadlock.
18-12-2022

We need to check self-close case anyway (to handle other issues) in close, so we can and probably should do something more helpful than blocking forever. Rather than returning if terminating, should it throw IllegalStateException? (We probably should have done something about this in awaitTermination as well, but too late for that.)
18-12-2022

If a worker thread invokes shutdown+awaitTermination on its own pool then it will block until it times out. The close method is essentially the same with an infinite timeout. So I think I would expect it to deadlock and a hazard for a worker thread to call awaitTermination or close.
18-12-2022

In the course of addressing this, I noticed that we don't say what happens if a worker thread invokes close on its own pool. In this case, we should return if the pool is terminating, but not terminated (because the current thread would otherwise be blocked waiting for itself to finish). This is inconsistently handled in current code, but will be made consistent. However, this also means that it may return when there are other terminating-but-not-terminated threads as well. I'm not sure this requires a spec change though.
18-12-2022

Additionally to the "sleep interrupted" issue, we run on macOS aarch64 into this error (java.lang.IllegalStateException) in the test java/util/concurrent/ExecutorService/CloseTest.java : test CloseTest.testCloseWithNoTasks(DelegatingExecutorService@6946d335): success test CloseTest.testCloseWithNoTasks(java.util.concurrent.ForkJoinPool@4f0c56cb): success test CloseTest.testCloseWithNoTasks(java.util.concurrent.ThreadPoolExecutor@95710fa): success test CloseTest.testCloseWithNoTasks(java.util.concurrent.ThreadPoolExecutor@19f0c1f4): success test CloseTest.testCloseWithNoTasks(java.util.concurrent.ThreadPerTaskExecutor@448dcdc): success test CloseTest.testCloseWithNoTasks(java.util.concurrent.ThreadPerTaskExecutor@5eeb56ca): success test CloseTest.testCloseWithRunningTasks(DelegatingExecutorService@29353dd4): success test CloseTest.testCloseWithRunningTasks(java.util.concurrent.ForkJoinPool@1399ac9f): success test CloseTest.testCloseWithRunningTasks(java.util.concurrent.ThreadPoolExecutor@14c7cd44): success test CloseTest.testCloseWithRunningTasks(java.util.concurrent.ThreadPoolExecutor@5a380016): success test CloseTest.testCloseWithRunningTasks(java.util.concurrent.ThreadPerTaskExecutor@13873685): success test CloseTest.testCloseWithRunningTasks(java.util.concurrent.ThreadPerTaskExecutor@414c6242): success test CloseTest.testInterruptBeforeClose(DelegatingExecutorService@60c0d42a): success test CloseTest.testInterruptBeforeClose(java.util.concurrent.ForkJoinPool@5498ee17): success test CloseTest.testInterruptBeforeClose(java.util.concurrent.ThreadPoolExecutor@79ef5ee4): success test CloseTest.testInterruptBeforeClose(java.util.concurrent.ThreadPoolExecutor@5426b27f): success test CloseTest.testInterruptBeforeClose(java.util.concurrent.ThreadPerTaskExecutor@1ec21c71): success test CloseTest.testInterruptBeforeClose(java.util.concurrent.ThreadPerTaskExecutor@4af8e934): success test CloseTest.testInterruptDuringClose(DelegatingExecutorService@5559ce45): success test CloseTest.testInterruptDuringClose(java.util.concurrent.ForkJoinPool@55de7cbc): success test CloseTest.testInterruptDuringClose(java.util.concurrent.ThreadPoolExecutor@779b0d58): success test CloseTest.testInterruptDuringClose(java.util.concurrent.ThreadPoolExecutor@f670591): success test CloseTest.testInterruptDuringClose(java.util.concurrent.ThreadPerTaskExecutor@7a06e5b5): success test CloseTest.testInterruptDuringClose(java.util.concurrent.ThreadPerTaskExecutor@15f34de3): success test CloseTest.testShutdownBeforeClose(DelegatingExecutorService@5135876f): success test CloseTest.testShutdownBeforeClose(java.util.concurrent.ForkJoinPool@2a4b5db9): failure java.lang.IllegalStateException at java.base/java.util.concurrent.ForkJoinTask.resultNow(ForkJoinTask.java:898) at CloseTest.testShutdownBeforeClose(CloseTest.java:113) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:578) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:132) at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:599) at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:174) at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46) at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:822) at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:147) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) at org.testng.TestRunner.privateRun(TestRunner.java:764) at org.testng.TestRunner.run(TestRunner.java:585) at org.testng.SuiteRunner.runTest(SuiteRunner.java:384) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337) at org.testng.SuiteRunner.run(SuiteRunner.java:286) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1218) at org.testng.TestNG.runSuitesLocally(TestNG.java:1140) at org.testng.TestNG.runSuites(TestNG.java:1069) at org.testng.TestNG.run(TestNG.java:1037) at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:93) at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:53) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:578) at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:125) at java.base/java.lang.Thread.run(Thread.java:1623) test CloseTest.testShutdownBeforeClose(java.util.concurrent.ThreadPoolExecutor@2c1f9e40): success test CloseTest.testShutdownBeforeClose(java.util.concurrent.ThreadPoolExecutor@2c5cde9): success test CloseTest.testShutdownBeforeClose(java.util.concurrent.ThreadPerTaskExecutor@74b716ea): success test CloseTest.testShutdownBeforeClose(java.util.concurrent.ThreadPerTaskExecutor@301b5252): success test CloseTest.testTerminateBeforeClose(DelegatingExecutorService@218bec59): success test CloseTest.testTerminateBeforeClose(java.util.concurrent.ForkJoinPool@76d0a93c): success test CloseTest.testTerminateBeforeClose(java.util.concurrent.ThreadPoolExecutor@5244aef0): success test CloseTest.testTerminateBeforeClose(java.util.concurrent.ThreadPoolExecutor@6cd87651): success test CloseTest.testTerminateBeforeClose(java.util.concurrent.ThreadPerTaskExecutor@6f609b9c): success test CloseTest.testTerminateBeforeClose(java.util.concurrent.ThreadPerTaskExecutor@2fd76bd7): success =============================================== java/util/concurrent/ExecutorService/CloseTest.java Total tests run: 36, Passes: 35, Failures: 1, Skips: 0 ===============================================
13-12-2022

Thanks for the diagnostic help. Both this and JDK-8286352 are due to created threads not actually starting until after termination. These cases require more checks that I'll look into.
18-10-2022

Jai gave me ssh access to a macos-aarch64 system where he duplicated it. It duplicated once for me. It appears that a second worker starts, registers, and immediately deregisters because the pool is shutdown. The deregister will tryTerminate where it scans the queues and interrupts the active worker that is executing the sleep task.
16-10-2022

I have not been able to duplicate this but as testShutdownBeforeClose is a very simple test then I can only guess that ForkJoinPool.tryTerminate is the source of the interrupt.
15-10-2022

I am now able to consistently reproduce this. I'll look deeper to see what's going on.
14-10-2022

Here's a log file snippet for the jdk-20+20-1379-tier1 sighting: java/util/concurrent/ExecutorService/CloseTest.java test CloseTest.testInterruptDuringClose(java.util.concurrent.ThreadPerTaskExecutor@65c7b893): success test CloseTest.testInterruptDuringClose(java.util.concurrent.ThreadPerTaskExecutor@4b3d1db8): success test CloseTest.testShutdownBeforeClose(DelegatingExecutorService@f072db0): success test CloseTest.testShutdownBeforeClose(java.util.concurrent.ForkJoinPool@6580a62d): failure java.lang.IllegalStateException at java.base/java.util.concurrent.ForkJoinTask.resultNow(ForkJoinTask.java:898) at CloseTest.testShutdownBeforeClose(CloseTest.java:113) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:578) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:132) at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:599) at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:174) at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46) at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:822) at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:147) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) at org.testng.TestRunner.privateRun(TestRunner.java:764) at org.testng.TestRunner.run(TestRunner.java:585) at org.testng.SuiteRunner.runTest(SuiteRunner.java:384) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337) at org.testng.SuiteRunner.run(SuiteRunner.java:286) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1218) at org.testng.TestNG.runSuitesLocally(TestNG.java:1140) at org.testng.TestNG.runSuites(TestNG.java:1069) at org.testng.TestNG.run(TestNG.java:1037) at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:93) at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:53) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:578) at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:125) at java.base/java.lang.Thread.run(Thread.java:1591) test CloseTest.testShutdownBeforeClose(java.util.concurrent.ThreadPoolExecutor@29594676): success test CloseTest.testShutdownBeforeClose(java.util.concurrent.ThreadPoolExecutor@320ccb8b): success test CloseTest.testShutdownBeforeClose(java.util.concurrent.ThreadPerTaskExecutor@70a78a): success test CloseTest.testShutdownBeforeClose(java.util.concurrent.ThreadPerTaskExecutor@6a3dfb34): success test CloseTest.testTerminateBeforeClose(DelegatingExecutorService@7d0b9fc8): success test CloseTest.testTerminateBeforeClose(java.util.concurrent.ForkJoinPool@12070d): success test CloseTest.testTerminateBeforeClose(java.util.concurrent.ThreadPoolExecutor@378c9348): success test CloseTest.testTerminateBeforeClose(java.util.concurrent.ThreadPoolExecutor@647d8cb): success test CloseTest.testTerminateBeforeClose(java.util.concurrent.ThreadPerTaskExecutor@54293ac5): success test CloseTest.testTerminateBeforeClose(java.util.concurrent.ThreadPerTaskExecutor@54fcbd3a): success =============================================== java/util/concurrent/ExecutorService/CloseTest.java Total tests run: 36, Passes: 35, Failures: 1, Skips: 0 =============================================== ----------System.err:(12/672)---------- java.lang.Exception: failures: 1 at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:95) at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:53) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:578) at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:125) at java.base/java.lang.Thread.run(Thread.java:1591) JavaTest Message: Test threw exception: java.lang.Exception: failures: 1 JavaTest Message: shutting down test STATUS:Failed.`main' threw exception: java.lang.Exception: failures: 1 ----------rerun:(36/7406)*---------- This second sighting is not the exact same failure mode: > test CloseTest.testShutdownBeforeClose(java.util.concurrent.ForkJoinPool@78e55947): failure > java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.InterruptedException: sleep interrupted versus (this one): > test CloseTest.testShutdownBeforeClose(java.util.concurrent.ForkJoinPool@6580a62d): failure > java.lang.IllegalStateException > at java.base/java.util.concurrent.ForkJoinTask.resultNow(ForkJoinTask.java:898)
13-10-2022

> It uses a timeout of 1d as there isn't a way to wait forever. There's existing code that "waits forever" using awaitTermination(Long.MAX_VALUE, anyUnit) Adding an untimed awaitTermination method seems reasonable.
24-06-2022

> A FJ worker thread calling shutdownNow does not interrupt itself. Do you think it should? ForkJoinPool's shutdownNow is underspecified. It's OK for the interface ExecutorService::shutdownNow to give freedom to implementers, but it's not OK for concrete implementations to not say exactly which interrupts will be delivered. Typically we end up specifying existing behavior, but I was surprised when I discovered there was a "current thread" exception to interrupting all running tasks. OTOH I was wearing the test-writer's hat, so don't trust myself. (think) ... I recommend documenting the current behavior.
24-06-2022

A FJ worker thread calling shutdownNow does not interrupt itself. Do you think it should?
24-06-2022

The default implementation of close calls awaitTermination in a loop so it is wait until termination. It uses a timeout of 1d as there isn't a way to wait forever. The override in FJP does the same although it could implement it without a timeout, it just won't really benefit. In any case, if close were interrupted then it re-assert the interrupt status after termination so the test would execute through to the Future::get with the interrupt status set, and it doesn't appear this is the case as the FJTask::get would throw InterruptedException.
24-06-2022

Hmmm ... time to actually read the spec https://download.java.net/java/early_access/jdk20/docs/api/java.base/java/util/concurrent/ExecutorService.html#close() [~alanb] I agree with your analysis. If the interrupt status was asserted, then awaitTermination would throw IE and never get to calling Future::get. I've run out of leads to investigate further. BTW, I still think default close() needs to wait "forever", not one day.
24-06-2022

If a thread invoking close is interrupted then it will "stop all tasks" with shutdowNow, essentially propagating the interrupt. So in this case, if the main thread is interrupted then it will interrupt the task too. The tests that ran just before the failing test do exercise interrupt and my initial assumption that was the interrupt of the main thread was somehow leaking through to the subsequent test. However, the stack trace shows that Future::get threw ExecutionException and not InterruptedException so it looks like the interrupt status on the main thread is not set. This leads to the question on whether a newly created thread could somehow be created with its interrupt status set. I don't see how this is possible. I've run this test several thousand times on each platform with both release and debug builds, no sighting.
23-06-2022

I took a look. The call to sleep that's getting an InterruptedException appears to be in a task executing inside a new ForkJoinPool(), so it should be very unlikely that a previous still executing test is managing to send it an interrupt - no test would try to interrupt every Thread in the system. I always worry about a vanishingly rare race found only on weak architecture machines.
23-06-2022

The failure did not reproduce in the next build-ID (jdk-19+28-2101-tier1) so I'm adding the 'intermittent' label.
21-06-2022

I re-ran this 1000 times on macosx-aarch64 but couldn't duplicate it. The TestNG output shows the tests that ran before it, maybe there is an issue with a previous test the interrupt of the main thread "escaped", leading to testShutdownBeforeClose failing.
21-06-2022