8158963: RMI server-side multiplex protocol should be disabled
Summary: add sun.rmi.transport.tcp.enableMultiplexProtocol to enable RMI multiplex protocol
Reviewed-by: smarks
--- a/jdk/src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPTransport.java Wed Nov 02 20:53:56 2016 +0300
+++ b/jdk/src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPTransport.java Wed Nov 02 13:42:03 2016 -0400
@@ -102,6 +102,11 @@
AccessController.doPrivileged((PrivilegedAction<Long>) () ->
Long.getLong("sun.rmi.transport.tcp.threadKeepAliveTime", 60000));
+ /** enable multiplexing protocol */
+ private static final boolean enableMultiplexProtocol = // default false
+ AccessController.doPrivileged((PrivilegedAction<Boolean>) () ->
+ Boolean.getBoolean("sun.rmi.transport.tcp.enableMultiplexProtocol"));
+
/** thread pool for connection handlers */
private static final ExecutorService connectionThreadPool =
new ThreadPoolExecutor(0, maxConnectionThreads,
@@ -796,6 +801,19 @@
break;
case TransportConstants.MultiplexProtocol:
+
+ if (!enableMultiplexProtocol) {
+ if (tcpLog.isLoggable(Log.VERBOSE)) {
+ tcpLog.log(Log.VERBOSE, "(port " + port +
+ ") rejecting multiplex protocol");
+ }
+
+ // If MultiplexProtocol is disabled, send NACK immediately.
+ out.writeByte(TransportConstants.ProtocolNack);
+ out.flush();
+ break;
+ }
+
if (tcpLog.isLoggable(Log.VERBOSE)) {
tcpLog.log(Log.VERBOSE, "(port " + port +
") accepting multiplex protocol");