src/java.base/share/classes/sun/security/ssl/TransportContext.java
changeset 51141 2dd2d73c52f6
parent 50768 68fa3d4026ea
child 51407 910f7b56592f
--- a/src/java.base/share/classes/sun/security/ssl/TransportContext.java	Wed Jul 18 11:57:51 2018 -0400
+++ b/src/java.base/share/classes/sun/security/ssl/TransportContext.java	Thu Jul 19 00:14:29 2018 +0800
@@ -393,6 +393,13 @@
     }
 
     void setUseClientMode(boolean useClientMode) {
+        // Once handshaking has begun, the mode can not be reset for the
+        // life of this engine.
+        if (handshakeContext != null || isNegotiated) {
+            throw new IllegalArgumentException(
+                    "Cannot change mode after SSL traffic has started");
+        }
+
         /*
          * If we need to change the client mode and the enabled
          * protocols and cipher suites haven't specifically been
@@ -400,13 +407,6 @@
          * default ones.
          */
         if (sslConfig.isClientMode != useClientMode) {
-            // Once handshaking has begun, the mode can not be reset for the
-            // life of this engine.
-            if (handshakeContext != null || isNegotiated) {
-                throw new IllegalArgumentException(
-                    "Cannot change mode after SSL traffic has started");
-            }
-
             if (sslContext.isDefaultProtocolVesions(
                     sslConfig.enabledProtocols)) {
                 sslConfig.enabledProtocols =