8049314: javax/net/ssl/templates/SSLSocketSSLEngineTemplate.java fails intermittently with "Unexpected EOF" message
authorasmotrak
Mon, 20 Jun 2016 17:06:27 -0700
changeset 39123 8c516d65ec4b
parent 39122 7c61c198e6c9
child 39124 2f46f5082cd7
8049314: javax/net/ssl/templates/SSLSocketSSLEngineTemplate.java fails intermittently with "Unexpected EOF" message Reviewed-by: xuelei
jdk/test/javax/net/ssl/templates/SSLSocketSSLEngineTemplate.java
--- a/jdk/test/javax/net/ssl/templates/SSLSocketSSLEngineTemplate.java	Tue Jun 21 00:45:52 2016 +0100
+++ b/jdk/test/javax/net/ssl/templates/SSLSocketSSLEngineTemplate.java	Mon Jun 20 17:06:27 2016 -0700
@@ -178,8 +178,11 @@
 
         char[] passphrase = "passphrase".toCharArray();
 
-        ks.load(new FileInputStream(keyFilename), passphrase);
-        ts.load(new FileInputStream(trustFilename), passphrase);
+        try (FileInputStream keyFile = new FileInputStream(keyFilename);
+                FileInputStream trustFile = new FileInputStream(trustFilename)) {
+            ks.load(keyFile, passphrase);
+            ts.load(trustFile, passphrase);
+        }
 
         KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
         kmf.init(ks, passphrase);
@@ -310,6 +313,7 @@
                             if (retry &&
                                     serverIn.remaining() < clientMsg.length) {
                                 log("Need to read more from client");
+                                serverIn.compact();
                                 retry = false;
                                 continue;
                             } else {