changeset 39123:8c516d65ec4b

8049314: javax/net/ssl/templates/SSLSocketSSLEngineTemplate.java fails intermittently with "Unexpected EOF" message Reviewed-by: xuelei
author asmotrak
date Mon, 20 Jun 2016 17:06:27 -0700
parents 7c61c198e6c9
children 2f46f5082cd7
files jdk/test/javax/net/ssl/templates/SSLSocketSSLEngineTemplate.java
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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 {