changeset 39317:fbda4d400372

8143302: javax/net/ssl/Stapling/SSLSocketWithStapling.java fails intermittently: Server died Summary: Fixes a file descriptor leak in the test and a thread exhaustion issue in the StatusResponseManager in JSSE. Reviewed-by: xuelei
author jnimeh
date Thu, 30 Jun 2016 00:09:06 -0700
parents 3042646f9b7b
children 2006d1d41c8b
files jdk/src/java.base/share/classes/sun/security/ssl/StatusResponseManager.java jdk/test/javax/net/ssl/Stapling/SSLSocketWithStapling.java
diffstat 2 files changed, 21 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/java.base/share/classes/sun/security/ssl/StatusResponseManager.java	Wed Jun 29 23:29:07 2016 -0700
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/StatusResponseManager.java	Thu Jun 30 00:09:06 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, 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
@@ -97,10 +97,11 @@
                 t.setDaemon(true);
                 return t;
             }
-        });
+        }, new ThreadPoolExecutor.DiscardPolicy());
         threadMgr.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
         threadMgr.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
         threadMgr.setKeepAliveTime(5000, TimeUnit.MILLISECONDS);
+        threadMgr.allowCoreThreadTimeOut(true);
         responseCache = Cache.newSoftMemoryCache(cacheCapacity, cacheLifetime);
     }
 
--- a/jdk/test/javax/net/ssl/Stapling/SSLSocketWithStapling.java	Wed Jun 29 23:29:07 2016 -0700
+++ b/jdk/test/javax/net/ssl/Stapling/SSLSocketWithStapling.java	Thu Jun 30 00:09:06 2016 -0700
@@ -510,25 +510,27 @@
         sslc.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
 
         SSLServerSocketFactory sslssf = sslc.getServerSocketFactory();
-        SSLServerSocket sslServerSocket =
-            (SSLServerSocket) sslssf.createServerSocket(serverPort);
 
-        serverPort = sslServerSocket.getLocalPort();
+        try (SSLServerSocket sslServerSocket =
+                (SSLServerSocket) sslssf.createServerSocket(serverPort)) {
 
-        /*
-         * Signal Client, we're ready for his connect.
-         */
-        serverReady = true;
+            serverPort = sslServerSocket.getLocalPort();
 
-        try (SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
-                InputStream sslIS = sslSocket.getInputStream();
-                OutputStream sslOS = sslSocket.getOutputStream()) {
-            int numberIn = sslIS.read();
-            int numberSent = 85;
-            log("Server received number: " + numberIn);
-            sslOS.write(numberSent);
-            sslOS.flush();
-            log("Server sent number: " + numberSent);
+            /*
+             * Signal Client, we're ready for his connect.
+             */
+            serverReady = true;
+
+            try (SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
+                    InputStream sslIS = sslSocket.getInputStream();
+                    OutputStream sslOS = sslSocket.getOutputStream()) {
+                int numberIn = sslIS.read();
+                int numberSent = 85;
+                log("Server received number: " + numberIn);
+                sslOS.write(numberSent);
+                sslOS.flush();
+                log("Server sent number: " + numberSent);
+            }
         }
     }