--- old/test/java/net/MulticastSocket/B6427403.java 2017-04-12 14:44:18.000000000 +0100 +++ new/test/java/net/MulticastSocket/B6427403.java 2017-04-12 14:44:18.000000000 +0100 @@ -23,20 +23,37 @@ /* * @test - * * @bug 6427403 - * * @summary java.net.MulticastSocket.joinGroup() reports 'socket closed' - * + * @library /lib/testlibrary + * @build jdk.testlibrary.NetworkConfiguration + * @run main B6427403 */ + +import java.io.IOException; import java.net.*; -import java.io.*; -import java.util.*; +import java.util.Optional; +import java.util.Set; +import jdk.testlibrary.NetworkConfiguration; + public class B6427403 { public static void main( String[] args ) throws IOException { InetAddress lh = InetAddress.getLocalHost(); - MulticastSocket ms = new MulticastSocket( new InetSocketAddress(lh, 0) ); - ms.joinGroup( InetAddress.getByName("224.80.80.80") ); - ms.close(); + System.out.println("localhost:" + lh); + + Optional onif = NetworkConfiguration.probe() + .ip4MulticastInterfaces() + .filter(addr -> addr.equals(lh)) + .findFirst(); + + if (onif.isPresent()) { + NetworkInterface nif = onif.get(); + System.out.println("nif:" + nif); + SocketAddress bindAddr = new InetSocketAddress(lh, 0); + try (MulticastSocket ms = new MulticastSocket(bindAddr)) { + ms.setNetworkInterface(nif); + ms.joinGroup(InetAddress.getByName("224.80.80.80")); + } + } } }