RFR: JDK-8265362 java/net/Socket/UdpSocket.java fails with "java.net.BindException: Address already in use" (macos-aarch64)

Mark Sheppard msheppar at openjdk.java.net
Fri May 21 17:03:12 UTC 2021


The test java/net/Socket/UdpSocket.java has been seen to fail with a BindException, in the testMaxSockets test, on a regular basis on macOS-aarch64 platform. testMaxSockets tests the maximum number of UDP Sockets that may be created as defined by a system property sun.net.maxDatagramSockets. It invokes the Socket constructor Socket(InetAddress host, int port, boolean stream) with stream set to false to create a UDP Socket. This instantiation is a compound operation, consisting of the creation of a socket, the explicit binding of wildcard address and ephemeral port, and a connect to the socket end point specified in the constructor parameters.  Analysis has shown that during the test that the OS intermittently allocates the same ephemeral port multiple times during the bind system call, such that two separate sockets end up bound to the same port. Then on the connect invocation a BindException is thrown for the second socket. This has been determined to be a transient condition during
  heavy loads and where a significant number of ephemeral ports are being allocated.

As this is deemed an OS issues, and in order to increase test stability, it has been found that for the BindException condition a retry of the Socket creation mitigates the issues and tests the max creation property.

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

Commit messages:
 - JDK-8265362 java/net/Socket/UdpSocket.java fails with "java.net.BindException: Address already in use" (macos-aarch64)
 - JDK-8265362: additions to execute a retry of UDP Socket construction if a BindException thrown during the testMaxSockets test

Changes: https://git.openjdk.java.net/jdk/pull/4103/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=4103&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8265362
  Stats: 14 lines in 2 files changed: 10 ins; 3 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/4103.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/4103/head:pull/4103

PR: https://git.openjdk.java.net/jdk/pull/4103


More information about the net-dev mailing list