8253368: TLS connection always receives close_notify exception

Reviewed-by: xuelei
This commit is contained in:
Sean Coffey 2020-12-23 12:26:44 +00:00
parent 4ea88512dd
commit a4e082e985
2 changed files with 37 additions and 12 deletions

View file

@ -820,16 +820,17 @@ public final class SSLSocketImpl
// Is it ready to close inbound?
//
// No need to throw exception if the initial handshake is not started.
if (checkCloseNotify && !conContext.isInputCloseNotified &&
(conContext.isNegotiated || conContext.handshakeContext != null)) {
throw conContext.fatal(Alert.INTERNAL_ERROR,
try {
if (checkCloseNotify && !conContext.isInputCloseNotified &&
(conContext.isNegotiated || conContext.handshakeContext != null)) {
throw new SSLException(
"closing inbound before receiving peer's close_notify");
}
conContext.closeInbound();
if ((autoClose || !isLayered()) && !super.isInputShutdown()) {
super.shutdownInput();
}
} finally {
conContext.closeInbound();
if ((autoClose || !isLayered()) && !super.isInputShutdown()) {
super.shutdownInput();
}
}
}