RFR: 8299813: java/nio/channels/DatagramChannel/Disconnect.java fails with jtreg test timeout due to lost datagram

Daniel Fuchs dfuchs at openjdk.org
Wed Jun 26 14:20:21 UTC 2024


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.

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

Commit messages:
 - fix mistake
 - skip receive if server port and client port are identical
 - Add some more debug traces
 - 8334600

Changes: https://git.openjdk.org/jdk/pull/19908/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=19908&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8299813
  Stats: 32 lines in 1 file changed: 19 ins; 0 del; 13 mod
  Patch: https://git.openjdk.org/jdk/pull/19908.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/19908/head:pull/19908

PR: https://git.openjdk.org/jdk/pull/19908


More information about the nio-dev mailing list