(teststabilization) RFR: 8231506: Fix some instabilities in a few networking tests

Daniel Fuchs daniel.fuchs at oracle.com
Mon Sep 30 12:37:45 UTC 2019


Hi Mark,

On 30/09/2019 12:56, mark sheppard wrote:
> the first uses the InetSocketAddress allocated and then the second uses the same address, without bind  exception because of
> the SO_REUSEADDR option being set,  even if the close had not completed at that time.

No. The second doesn't use the address. I agree that it might - if
e.g. the system has run out of ephemeral ports, but I believe  it's
highly unlikely.

$ jshell
jshell>  InetSocketAddress clientAddress =
    ...>                 new 
InetSocketAddress(InetAddress.getLoopbackAddress(), 0);
clientAddress ==> localhost/127.0.0.1:0

jshell>        try (MulticastSocket s = new 
MulticastSocket(clientAddress)) {
    ...>             // no-op; close immediately
    ...>             System.out.println(s.getLocalPort());
    ...> }
59951

jshell> MulticastSocket s = new MulticastSocket(clientAddress);
s ==> java.net.MulticastSocket at 1a86f2f1

jshell> System.out.println(s.getLocalPort());
55379

best regards,

-- daniel


More information about the net-dev mailing list