RFR: 8299813: java/nio/channels/DatagramChannel/Disconnect.java fails with jtreg test timeout due to lost datagram
Aleksei Efimov
aefimov at openjdk.org
Fri Jun 28 09:53:22 UTC 2024
On Wed, 26 Jun 2024 14:15:23 GMT, Daniel Fuchs <dfuchs 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.
-------------
Marked as reviewed by aefimov (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/19908#pullrequestreview-2147524606
More information about the nio-dev
mailing list