--- old/src/java.base/share/classes/java/net/ServerSocket.java 2018-10-05 14:14:32.451756902 -0700 +++ new/src/java.base/share/classes/java/net/ServerSocket.java 2018-10-05 14:14:32.179756899 -0700 @@ -76,10 +76,12 @@ private boolean oldImpl = false; /** - * Package-private constructor to create a ServerSocket associated with - * the given SocketImpl. + * Creates a server socket with a user-specified SocketImpl. + * + * @param impl the user-specified SocketImpl + * @since 12 */ - ServerSocket(SocketImpl impl) { + protected ServerSocket(SocketImpl impl) { this.impl = impl; impl.setServerSocket(this); } @@ -990,6 +992,8 @@ private static Set> options; private static boolean optionsSet = false; + private static Set> rdmaOptions; + private static boolean rdmaOptionsSet = false; /** * Returns a set of the socket options supported by this server socket. @@ -1004,16 +1008,29 @@ */ public Set> supportedOptions() { synchronized (ServerSocket.class) { - if (optionsSet) { - return options; - } try { SocketImpl impl = getImpl(); - options = Collections.unmodifiableSet(impl.supportedOptions()); + String implName = impl.getClass().getName(); + if (implName.equals("jdk.internal.net.rdma.RdmaSocketImpl")) { + if (rdmaOptionsSet) + return rdmaOptions; + rdmaOptions = Collections.unmodifiableSet( + impl.supportedOptions()); + rdmaOptionsSet = true; + return rdmaOptions; + } else { + if (optionsSet) + return options; + options = Collections.unmodifiableSet( + impl.supportedOptions()); + optionsSet = true; + return options; + } } catch (IOException e) { options = Collections.emptySet(); + rdmaOptions = Collections.emptySet(); } - optionsSet = true; + //should not reach here return options; } }