RFR: 8293696: java/nio/channels/DatagramChannel/SelectWhenRefused.java fails with "Unexpected wakeup" [v2]
Darragh Clarke
duke at openjdk.org
Fri Oct 28 13:23:29 UTC 2022
On Fri, 28 Oct 2022 08:32:06 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:
>> No I believe scenario 2 is different - but you are right - it would be more correct to replace lines 90-91 with this:
>>
>>
>> // BindException will be thrown if another service is using
>> // our expected refuser port, cannot run just exit.
>> DatagramChannel.open().bind(refuser).close();
>> throw new RuntimeException("PortUnreachableException not raised");
>>
>>
>> In other words: we are connected - so we could only receive a message from something bound to the refuser's port. So check whether that port is still unbound, and if so, complain that PortUnreachableException should have been received.
>> Note that there still might be a race condition here because something could have transiently bound to the refuser and then released it. But the window of opportunity for the race should be smaller.
>> Whether we should `throw new RuntimeException("PortUnreachableException not raised");` or simply `continue` and try again could be discussed.
>
>> Maybe change the send message to be completely unique to this test, there maybe other DatagramSocket or Channel tests that have message containing "Greetings"
>
> Good point. Although it's the only one I could find that uses Datagrams. We could add a time stamp - or a UUID for extra security.
I think even something as simple as changing the message to ``Greetings from SelectWhenRefused!`` makes it unique, though I could do a UUID too?
-------------
PR: https://git.openjdk.org/jdk/pull/10851
More information about the nio-dev
mailing list