RFR: 8347173: java/net/DatagramSocket/InterruptibleDatagramSocket.java fails with virtual thread factory [v2]

Daniel Fuchs dfuchs at openjdk.org
Mon Jan 13 15:47:45 UTC 2025


On Mon, 13 Jan 2025 14:42:04 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

>> Can I please get a review for this test-only change which proposes to skip this test when the `main()` is launched through a virtual thread?
>> 
>> This test was introduced in https://bugs.openjdk.org/browse/JDK-8233018 , before virtual threads were introduced. In its current form the test doesn't take into account the specification of `DatagramSocket.receive()` when a virtual thread is doing the `receive()`. There's already the `test/jdk/java/net/vthread/BlockingSocketOps.java` test which exercises the `receive()` through a virtual thread and verifies its specified behaviour, so we can skip this `InterruptibleDatagramSocket` test when a virtual thread is involved.
>> 
>> With the proposed change, the test no longer fails and is reported as skipped by jtreg.
>
> Jaikiran Pai has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Alan's review - update skip reason

test/jdk/java/net/DatagramSocket/InterruptibleDatagramSocket.java line 104:

> 102:             throw new jtreg.SkippedException(
> 103:                     "skipping test execution - main thread is a virtual thread");
> 104:         }

I wonder - would it work instead to replace:

test(s, false);

with

test(s, Thread.currentThread().isVirtual());


I am not sure it would work - because the exception that gets thrown could be different... But this would be a way to test both the main-is-virtual and main-is-not-virtual cases.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23074#discussion_r1913404913


More information about the net-dev mailing list