changeset 16003:88d82306b232

8158963: RMI server-side multiplex protocol should be disabled Summary: add sun.rmi.transport.tcp.enableMultiplexProtocol to enable RMI multiplex protocol Reviewed-by: smarks
author rriggs
date Wed, 02 Nov 2016 13:42:03 -0400
parents 50dd63d47f2d
children 1396fb6d0279
files src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPTransport.java
diffstat 1 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPTransport.java	Wed Nov 02 20:53:56 2016 +0300
+++ b/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");