--- old/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java 2020-03-10 15:48:43.237551000 +0100 +++ new/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java 2020-03-10 15:48:42.422544000 +0100 @@ -618,9 +618,8 @@ // Need a lock here so that the user_canceled alert and the // close_notify alert can be delivered together. - conContext.outputRecord.recordLock.lock(); try { - try { + synchronized (conContext.outputRecord) { // send a user_canceled alert if needed. if (useUserCanceled) { conContext.warning(Alert.USER_CANCELED); @@ -628,17 +627,15 @@ // send a close_notify alert conContext.warning(Alert.CLOSE_NOTIFY); - } finally { - if (!conContext.isOutboundClosed()) { - conContext.outputRecord.close(); - } - - if ((autoClose || !isLayered()) && !super.isOutputShutdown()) { - super.shutdownOutput(); - } } } finally { - conContext.outputRecord.recordLock.unlock(); + if (!conContext.isOutboundClosed()) { + conContext.outputRecord.close(); + } + + if ((autoClose || !isLayered()) && !super.isOutputShutdown()) { + super.shutdownOutput(); + } } if (!isInputShutdown()) {