On Tue, 27 Oct 2026 11:06:20 GMT, Viktor Klang <[email protected]> wrote:

>> test/jdk/java/util/concurrent/forkjoin/AsyncShutdownNowInvokeAnyRace.java 
>> line 114:
>> 
>>> 112:             Future<Void> shutdownResult = 
>>> CompletableFuture.runAsync(shutdown);
>>> 113: 
>>> 114:             try (pool) { // Ensure that the pool is terminated after 
>>> each iteration
>> 
>> Replacing
>> 
>>     try {
>>         try {
>>             invokeAny();
>>         } catch (...) {
>>             ...
>>         }
>>     } finally {
>>         pool.shutdown();
>>     }
>> 
>> with
>> 
>>     try (pool) {
>>        invokeAny();
>>     } catch (...) {
>>         ...
>>     }
>> 
>> has a semantic difference: earlier, `catch` clauses were kicking in right 
>> after an `invokeAny()` failure; now, `catch` clauses kick in after 
>> `pool.close()`, which might block due to stale workers, and consequently 
>> short-circuit catch clauses, e.g., `catch (TimeoutException ...)` might get 
>> skipped.
>> 
>> @viktorklang-ora, is this change intentional or harmless?
>
>>and consequently short-circuit catch clauses, e.g., catch (TimeoutException 
>>...) might get skipped.
> 
> I might be missing something, but the contents of the try-body needs to 
> execute before the finally, so the TimeoutException will be thrown *before* 
> pool.close() is called (and then subsequently be handled by the catch). What 
> might be affected though, is the dumping of threads, which is indeed an 
> oversight. Let me open another issue to do the double-try (which also means 
> that I can update the copyright year.

Opened https://bugs.openjdk.org/browse/JDK-8395898

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/33453#discussion_r4387950522

Reply via email to