8237578: JDK-8214339 (SSLSocketImpl wraps SocketException) appears to not be fully fixed

Reviewed-by: xuelei, simonis
This commit is contained in:
Clive Verghese 2021-01-11 12:02:09 +00:00 committed by Volker Simonis
parent 1bd015fb0c
commit 01b2804ef7
5 changed files with 182 additions and 7 deletions

View file

@ -447,6 +447,8 @@ public final class SSLSocketImpl
throw conContext.fatal(Alert.HANDSHAKE_FAILURE,
"Couldn't kickstart handshaking", iioe);
}
} catch (SocketException se) {
handleException(se);
} catch (IOException ioe) {
throw conContext.fatal(Alert.HANDSHAKE_FAILURE,
"Couldn't kickstart handshaking", ioe);
@ -1411,6 +1413,9 @@ public final class SSLSocketImpl
} catch (InterruptedIOException iioe) {
// don't change exception in case of timeouts or interrupts
throw iioe;
} catch (SocketException se) {
// don't change exception in case of SocketException
throw se;
} catch (IOException ioe) {
throw new SSLException("readHandshakeRecord", ioe);
}
@ -1476,6 +1481,9 @@ public final class SSLSocketImpl
} catch (InterruptedIOException iioe) {
// don't change exception in case of timeouts or interrupts
throw iioe;
} catch (SocketException se) {
// don't change exception in case of SocketException
throw se;
} catch (IOException ioe) {
if (!(ioe instanceof SSLException)) {
throw new SSLException("readApplicationRecord", ioe);
@ -1687,6 +1695,16 @@ public final class SSLSocketImpl
}
}
if (cause instanceof SocketException) {
try {
conContext.fatal(alert, cause);
} catch (Exception e) {
// Just delivering the fatal alert, re-throw the socket exception instead.
}
throw (SocketException)cause;
}
throw conContext.fatal(alert, cause);
}

View file

@ -28,6 +28,7 @@ package sun.security.ssl;
import java.io.EOFException;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.SocketException;
import java.nio.ByteBuffer;
import javax.crypto.AEADBadTagException;
import javax.crypto.BadPaddingException;
@ -140,6 +141,9 @@ interface SSLTransport {
} catch (InterruptedIOException iioe) {
// don't close the Socket in case of timeouts or interrupts.
throw iioe;
} catch (SocketException se) {
// don't change exception in case of SocketException
throw se;
} catch (IOException ioe) {
throw context.fatal(Alert.UNEXPECTED_MESSAGE, ioe);
}