--- old/src/jdk.net/linux/classes/jdk/internal/net/rdma/RdmaServerSocketChannelImpl.java 2018-12-04 19:57:49.542205394 +0000 +++ new/src/jdk.net/linux/classes/jdk/internal/net/rdma/RdmaServerSocketChannelImpl.java 2018-12-04 19:57:49.085977395 +0000 @@ -27,6 +27,7 @@ import java.io.FileDescriptor; import java.io.IOException; +import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.ProtocolFamily; import java.net.ServerSocket; @@ -41,6 +42,7 @@ import java.nio.channels.SelectionKey; import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; +import java.nio.channels.UnsupportedAddressTypeException; import java.nio.channels.spi.SelectorProvider; import java.util.Collections; import java.util.HashSet; @@ -54,6 +56,8 @@ import sun.nio.ch.SelChImpl; import sun.nio.ch.SelectionKeyImpl; import sun.net.ext.RdmaSocketOptions; +import static java.net.StandardProtocolFamily.INET; +import static java.net.StandardProtocolFamily.INET6; public class RdmaServerSocketChannelImpl extends ServerSocketChannel @@ -98,12 +102,11 @@ throws IOException { super(checkSupported(sp)); Objects.requireNonNull(family, "'family' is null"); - if ((family != StandardProtocolFamily.INET) && - (family != StandardProtocolFamily.INET6)) { + if (!(family == INET || family == INET6)) { throw new UnsupportedOperationException( "Protocol family not supported"); } - if (family == StandardProtocolFamily.INET6) { + if (family == INET6) { if (!Net.isIPv6Available()) { throw new UnsupportedOperationException( "IPv6 not available"); @@ -194,6 +197,15 @@ return DefaultOptionsHolder.defaultOptions; } + private final InetSocketAddress anyLocalAddress() throws IOException { + if (family == INET) + return new InetSocketAddress(InetAddress.getByName("0.0.0.0"), 0); + else if (family == INET6) + return new InetSocketAddress(InetAddress.getByName("::"), 0); + else + throw new UnsupportedAddressTypeException(); + } + @Override public ServerSocketChannel bind(SocketAddress local, int backlog) throws IOException { @@ -202,7 +214,7 @@ if (localAddress != null) throw new AlreadyBoundException(); InetSocketAddress isa = (local == null) - ? new InetSocketAddress(0) + ? anyLocalAddress() : RdmaNet.checkAddress(local, family); SecurityManager sm = System.getSecurityManager(); if (sm != null)