mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8246031: SSLSocket.getSession() doesn't close connection for timeout/ interrupts
Reviewed-by: xuelei, coffeys
This commit is contained in:
parent
4862a00f6b
commit
bb86779366
2 changed files with 267 additions and 6 deletions
|
@ -354,7 +354,7 @@ public final class SSLSocketImpl
|
|||
public SSLSession getSession() {
|
||||
try {
|
||||
// start handshaking, if failed, the connection will be closed.
|
||||
ensureNegotiated();
|
||||
ensureNegotiated(false);
|
||||
} catch (IOException ioe) {
|
||||
if (SSLLogger.isOn && SSLLogger.isOn("handshake")) {
|
||||
SSLLogger.severe("handshake failed", ioe);
|
||||
|
@ -409,6 +409,10 @@ public final class SSLSocketImpl
|
|||
|
||||
@Override
|
||||
public void startHandshake() throws IOException {
|
||||
startHandshake(true);
|
||||
}
|
||||
|
||||
private void startHandshake(boolean resumable) throws IOException {
|
||||
if (!isConnected) {
|
||||
throw new SocketException("Socket is not connected");
|
||||
}
|
||||
|
@ -437,7 +441,12 @@ public final class SSLSocketImpl
|
|||
readHandshakeRecord();
|
||||
}
|
||||
} catch (InterruptedIOException iioe) {
|
||||
handleException(iioe);
|
||||
if(resumable){
|
||||
handleException(iioe);
|
||||
} else{
|
||||
throw conContext.fatal(Alert.HANDSHAKE_FAILURE,
|
||||
"Couldn't kickstart handshaking", iioe);
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
throw conContext.fatal(Alert.HANDSHAKE_FAILURE,
|
||||
"Couldn't kickstart handshaking", ioe);
|
||||
|
@ -867,7 +876,7 @@ public final class SSLSocketImpl
|
|||
}
|
||||
}
|
||||
|
||||
private void ensureNegotiated() throws IOException {
|
||||
private void ensureNegotiated(boolean resumable) throws IOException {
|
||||
if (conContext.isNegotiated || conContext.isBroken ||
|
||||
conContext.isInboundClosed() || conContext.isOutboundClosed()) {
|
||||
return;
|
||||
|
@ -882,7 +891,7 @@ public final class SSLSocketImpl
|
|||
return;
|
||||
}
|
||||
|
||||
startHandshake();
|
||||
startHandshake(resumable);
|
||||
} finally {
|
||||
handshakeLock.unlock();
|
||||
}
|
||||
|
@ -973,7 +982,7 @@ public final class SSLSocketImpl
|
|||
if (!conContext.isNegotiated && !conContext.isBroken &&
|
||||
!conContext.isInboundClosed() &&
|
||||
!conContext.isOutboundClosed()) {
|
||||
ensureNegotiated();
|
||||
ensureNegotiated(true);
|
||||
}
|
||||
|
||||
// Check if the Socket is invalid (error or closed).
|
||||
|
@ -1252,7 +1261,7 @@ public final class SSLSocketImpl
|
|||
if (!conContext.isNegotiated && !conContext.isBroken &&
|
||||
!conContext.isInboundClosed() &&
|
||||
!conContext.isOutboundClosed()) {
|
||||
ensureNegotiated();
|
||||
ensureNegotiated(true);
|
||||
}
|
||||
|
||||
// Check if the Socket is invalid (error or closed).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue