changeset 14424:4a65e6e3116a

8258753: StartTlsResponse.close() hangs due to synchronization issues Reviewed-by: xuelei Contributed-by: Prajwal Kumaraswamy <pkumaraswamy@openjdk.org>
author xuelei
date Thu, 25 Mar 2021 03:35:49 +0000
parents 06dcb7564c86
children c703b68365fb
files src/share/classes/sun/security/ssl/SSLSocketImpl.java
diffstat 1 files changed, 15 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/security/ssl/SSLSocketImpl.java	Thu May 18 12:53:19 2017 -0700
+++ b/src/share/classes/sun/security/ssl/SSLSocketImpl.java	Thu Mar 25 03:35:49 2021 +0000
@@ -1648,17 +1648,23 @@
             SSLLogger.fine("wait for close_notify or alert");
         }
 
-        while (!conContext.isInboundClosed()) {
-            try {
-                Plaintext plainText = decode(null);
-                // discard and continue
-                if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
-                    SSLLogger.finest(
-                        "discard plaintext while waiting for close", plainText);
+        appInput.readLock.lock();
+        try {
+            while (!conContext.isInboundClosed()) {
+                try {
+                    Plaintext plainText = decode(null);
+                    // discard and continue
+                    if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+                        SSLLogger.finest(
+                                "discard plaintext while waiting for close",
+                                plainText);
+                    }
+                } catch (Exception e) {   // including RuntimeException
+                    handleException(e);
                 }
-            } catch (Exception e) {   // including RuntimeException
-                handleException(e);
             }
+        } finally {
+            appInput.readLock.unlock();
         }
     }
 }