On Wed, 26 Aug 2026 10:19:28 GMT, Viktor Klang <[email protected]> wrote:
>> Fabian Meumertzheim has updated the pull request incrementally with one
>> additional commit since the last revision:
>>
>> Address second round of comments
>
> test/jdk/java/util/concurrent/forkjoin/GetMultipleWaiters.java line 62:
>
>> 60: } catch (Throwable ignore) {
>> 61: }
>> 62: }, "Get-waiter-B", Thread.State.WAITING);
>
> I wonder if we really need `b` if we launch this test in othervm with a
> timeout. Would you mind trying removing `b` and calling `task.get(…)` on the
> main thread and seeing if that is enough? It would save a chunk of test case
> complexity if it pans out.
I may have misunderstood the simplification, but this is what I tried. It did
not reproduce the issue without the fix applied:
/*
* @test
* @bug 8390870
* @summary ForkJoinTask.get must honor its timeout and interrupts even
* when another thread is waiting on the same task.
* @run junit/othervm/timeout=20 GetMultipleWaitersSimplified
*/
import java.util.concurrent.ForkJoinTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertThrows;
class GetMultipleWaiters {
/**
* get() on the main thread must be interruptible while another
* thread is waiting on the same task.
*/
@Test
void testGet() throws Exception {
var task = ForkJoinTask.adapt(() -> {});
var a = startThreadAndAwaitState(() -> {
try {
task.get();
} catch (Throwable ignore) {
}
}, "Get-waiter-A", Thread.State.WAITING);
try {
Thread.currentThread().interrupt();
assertThrows(InterruptedException.class, () -> task.get());
} finally {
task.complete(null);
a.join();
}
}
}
As far as I understand the CAS bug, this is because the waiter that is
interrupted needs to be the first on the stack, but here it would be the last.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/32485#discussion_r3862071141