RFR: 8269616: serviceability/dcmd/framework/VMVersionTest.java fails with Address already in use error

Alex Menkov amenkov at openjdk.java.net
Fri Jul 2 21:32:01 UTC 2021


SocketIOPipe/IOPipe classes can select listening port by 2 ways:
1. caller specifies "-transport.address=dynamic" argument creating ArgumentHandler,
and calls Binder.prepareForPipeConnection (actually see nsk.share.jpda.DebugeeBinder.prepareForPipeConnection()) before start listening.
In the case prepareForPipeConnection creates socket and this socket later is used by IOPipe.
2. just start IOPipe listening.
Then port is selected by calling nsk.share.jpda.DebugeeArgumentHandler.getTransportPort() which use findFreePort() method:

    ServerSocket ss;
    try {
        ss = new ServerSocket(0);
        return String.valueOf(ss.getLocalPort());
    }finally {
        ss.close();
    }

This method is known to be error prone (sometimes causes "address in use" error).

The fix adds "-transport.address=dynamic" argument so IOPipe use 1st method.

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

Commit messages:
 - Fixed "address in use" error

Changes: https://git.openjdk.java.net/jdk/pull/4676/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=4676&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8269616
  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/4676.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/4676/head:pull/4676

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


More information about the serviceability-dev mailing list