# HG changeset patch # User xuelei # Date 1616643349 0 # Node ID 4a65e6e3116a767ed688fac615a62f414f2c7f63 # Parent 06dcb7564c86523fa5e0e0798916a0690dcc31d7 8258753: StartTlsResponse.close() hangs due to synchronization issues Reviewed-by: xuelei Contributed-by: Prajwal Kumaraswamy diff -r 06dcb7564c86 -r 4a65e6e3116a src/share/classes/sun/security/ssl/SSLSocketImpl.java --- 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(); } } }