src/java.base/share/classes/sun/security/ssl/HandshakeOutStream.java
branchJDK-8145252-TLS13-branch
changeset 56542 56aaa6cb3693
parent 47216 71c04702a3d5
child 51407 910f7b56592f
--- a/src/java.base/share/classes/sun/security/ssl/HandshakeOutStream.java	Fri May 11 14:55:56 2018 -0700
+++ b/src/java.base/share/classes/sun/security/ssl/HandshakeOutStream.java	Fri May 11 15:53:12 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -56,11 +56,12 @@
             throw new RuntimeException("handshake message is not available");
         }
 
-        // outputRecord cannot be null
-        outputRecord.encodeHandshake(buf, 0, count);
+        if (outputRecord != null) {
+            outputRecord.encodeHandshake(buf, 0, count);
 
-        // reset the byte array output stream
-        reset();
+            // reset the byte array output stream
+            reset();
+        }   // otherwise, the handshake outstream is temporarily used only.
     }
 
     //
@@ -76,7 +77,9 @@
 
     @Override
     public void flush() throws IOException {
-        outputRecord.flush();
+        if (outputRecord != null) {
+            outputRecord.flush();
+        }
     }
 
     //
@@ -106,6 +109,13 @@
         super.write(i);
     }
 
+    void putInt32(int i) throws IOException {
+        super.write(i >> 24);
+        super.write(i >> 16);
+        super.write(i >> 8);
+        super.write(i);
+    }
+
     /*
      * Put byte arrays with length encoded as 8, 16, 24 bit
      * integers in big-endian format.