From 2047da7dccacb1adb7f811639a58b8fbe1aa3546 Mon Sep 17 00:00:00 2001 From: Fernando Guallini Date: Thu, 17 Jun 2021 16:23:56 +0000 Subject: [PATCH] 8265297: javax/net/ssl/SSLSession/TestEnabledProtocols.java failed with "RuntimeException: java.net.SocketException: Connection reset" Reviewed-by: xuelei, rhalade --- .../net/ssl/SSLSession/TestEnabledProtocols.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/test/jdk/javax/net/ssl/SSLSession/TestEnabledProtocols.java b/test/jdk/javax/net/ssl/SSLSession/TestEnabledProtocols.java index c2b22d5f7a7..4e56a9a655b 100644 --- a/test/jdk/javax/net/ssl/SSLSession/TestEnabledProtocols.java +++ b/test/jdk/javax/net/ssl/SSLSession/TestEnabledProtocols.java @@ -38,6 +38,7 @@ * @author Ram Marti */ +import java.io.IOException; import java.io.InputStream; import java.io.InterruptedIOException; import java.io.OutputStream; @@ -136,13 +137,13 @@ public class TestEnabledProtocols extends SSLSocketTemplate { 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) { @@ -150,8 +151,8 @@ public class TestEnabledProtocols extends SSLSocketTemplate { } } - private boolean isConnectionReset(SSLException ssle) { - Throwable cause = ssle.getCause(); + private boolean isConnectionReset(IOException ioe) { + Throwable cause = ioe instanceof SSLException se ? se.getCause() : ioe; return cause instanceof SocketException && "Connection reset".equals(cause.getMessage()); }