RFR: 8299813: java/nio/channels/DatagramChannel/Disconnect.java fails with jtreg test timeout due to lost datagram
Daniel Fuchs
dfuchs at openjdk.org
Fri Jun 28 10:20:18 UTC 2024
On Fri, 28 Jun 2024 09:50:50 GMT, Aleksei Efimov <aefimov at openjdk.org> wrote:
>> Please find here a simple fix to solve an intermittent failure in java/nio/channels/DatagramChannel/Disconnect.java
>>
>> On some platform, the underlying system may allow two datagram sockets to bind to the same port, if one of them uses the wildcard address and the other doesn't.
>>
>> What happens here is that during DC:connect, if the socket is unbound, it will get bound to the wildcard.
>> From time to time, this results into binding to the same port that the `server` is using in the test.
>> When that happens, datagram sent to the connected server may get misrouted and may not get delivered, and the call server::receive may block forever.
>>
>> This change does two things:
>> 1. explicitly bind the server to the loopback address instead of InetAddress.getLocalHost()
>> 2. skip the receive part of the test if the client local address obtained after connecting uses the same port than the server.
>>
>> This is rare, and skipping the receive part in that case does not invalidate the test.
>
> The changes look good to me.
Thanks @AlekseiEfimov ! If I don't receive further feedback I will integrate shortly
-------------
PR Comment: https://git.openjdk.org/jdk/pull/19908#issuecomment-2196577027
More information about the nio-dev
mailing list