[12] RFR 8199931: java/net/MulticastSocket/UnreferencedMulticastSockets.java fails with "incorrect data received"

Chris Yin xu.y.yin at oracle.com
Thu Sep 20 09:30:01 UTC 2018

Please review below minor change for 8199931, thanks

A little explanation about the change here, since the failure samples are too less (seems too hard to repro), so below scenario which caused the failure is a guess. MultcastSocket constructor set reuse address true by default, when call “new MulticastSocket(0)” to create client socket that maybe in a little possibility it used same address with server, that will explain why the failure looks like client received data package from itself. Follow the guessing, I modified test code to explicit create client socket use same port with server, then got same failure error as reported bug on OEL7. Though I cannot make sure the guess is 100% match with the original failure, but at least we could try to prevent such possible scenario.

bug: https://bugs.openjdk.java.net/browse/JDK-8199931


diff -r 43668e3cae4d test/jdk/java/net/MulticastSocket/UnreferencedMulticastSockets.java
--- a/test/jdk/java/net/MulticastSocket/UnreferencedMulticastSockets.java	Thu Sep 20 08:59:03 2018 +0200
+++ b/test/jdk/java/net/MulticastSocket/UnreferencedMulticastSockets.java	Thu Sep 20 16:37:36 2018 +0800
@@ -40,6 +40,7 @@
 import java.net.DatagramSocket;
 import java.net.DatagramSocketImpl;
 import java.net.InetAddress;
+import java.net.InetSocketAddress;
 import java.net.MulticastSocket;
 import java.net.UnknownHostException;
 import java.nio.file.Files;
@@ -119,7 +120,10 @@
         Thread thr = new Thread(svr);
-        MulticastSocket client = new MulticastSocket(0);
+        MulticastSocket client = new MulticastSocket(null);
+        // prevent MulticastSocket reuse previous address, see 8199931
+        client.setReuseAddress(false);
+        client.bind(new InetSocketAddress(0));
         client.connect(svr.getHost(), svr.getPort());
         pendingSockets.add(new NamedWeak(client, pendingQueue, "clientMulticastSocket"));
         extractRefs(client, "clientMulticastSocket”);


More information about the core-libs-dev mailing list