Skip to content

Commit

Permalink
8265297: javax/net/ssl/SSLSession/TestEnabledProtocols.java failed wi…
Browse files Browse the repository at this point in the history
…th "RuntimeException: java.net.SocketException: Connection reset"

Reviewed-by: mdoerr
Backport-of: 2047da7
  • Loading branch information
GoeLin committed Apr 7, 2022
1 parent 6cc8d69 commit 67c4882
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions test/jdk/javax/net/ssl/SSLSession/TestEnabledProtocols.java
Expand Up @@ -38,6 +38,7 @@
* @author Ram Marti
*/

import java.io.IOException;
import java.io.InputStream;
import java.io.InterruptedIOException;
import java.io.OutputStream;
Expand Down Expand Up @@ -135,22 +136,25 @@ protected void runClientApplication(SSLSocket sslSocket) throws Exception {
e.printStackTrace(System.out);
System.out.println("** Success **");
}
} catch (SSLException ssle) {
} catch (SSLException | SocketException se) {
// The server side may have closed the socket.
if (isConnectionReset(ssle)) {
System.out.println("Client SSLException:");
ssle.printStackTrace(System.out);
if (isConnectionReset(se)) {
System.out.println("Client SocketException:");
se.printStackTrace(System.out);
} else {
failTest(ssle, "Client got UNEXPECTED SSLException:");
failTest(se, "Client got UNEXPECTED Exception:");
}

} catch (Exception e) {
failTest(e, "Client got UNEXPECTED Exception:");
}
}

private boolean isConnectionReset(SSLException ssle) {
Throwable cause = ssle.getCause();
private boolean isConnectionReset(IOException ioe) {
Throwable cause = ioe;
if (ioe instanceof SSLException) {
cause = ioe.getCause();
}
return cause instanceof SocketException
&& "Connection reset".equals(cause.getMessage());
}
Expand Down

1 comment on commit 67c4882

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.