8028562: Test SSLSocketSSLEngineTemplate.java intermittent failed with "Data length error"
authorxuelei
Sun, 15 Dec 2013 20:24:45 -0800
changeset 22047 7980346542b6
parent 22046 b7163958d6d9
child 22048 0bd1f4ebe75f
8028562: Test SSLSocketSSLEngineTemplate.java intermittent failed with "Data length error" Summary: test stabilization, read one more time in case of message fragment Reviewed-by: mullan, xuelei Contributed-by: Zaiyao Liu <zaiyao.liu@oracle.com>
jdk/test/sun/security/ssl/templates/SSLSocketSSLEngineTemplate.java
--- a/jdk/test/sun/security/ssl/templates/SSLSocketSSLEngineTemplate.java	Sun Dec 15 08:11:41 2013 +0000
+++ b/jdk/test/sun/security/ssl/templates/SSLSocketSSLEngineTemplate.java	Sun Dec 15 20:24:45 2013 -0800
@@ -221,6 +221,9 @@
 
         try {
             boolean closed = false;
+            // will try to read one more time in case client message
+            // is fragmented to multiple pieces
+            boolean retry = true;
 
             InputStream is = socket.getInputStream();
             OutputStream os = socket.getOutputStream();
@@ -295,8 +298,14 @@
                     /*
                      * A sanity check to ensure we got what was sent.
                      */
-                    if (serverIn.remaining() != clientMsg.length) {
-                        throw new Exception("Client:  Data length error");
+                    if (serverIn.remaining() !=  clientMsg.length) {
+                        if (retry && serverIn.remaining() < clientMsg.length) {
+                            log("Need to read more from client");
+                            retry = false;
+                            continue;
+                        } else {
+                            throw new Exception("Client:  Data length error");
+                        }
                     }
 
                     for (int i = 0; i < clientMsg.length; i++) {