sun/net/www/protocol/https/HttpsURLConnection/ReadTimeout.java adapts to new exception hierarchy
--- a/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/ReadTimeout.java Tue May 22 21:46:47 2018 -0700
+++ b/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/ReadTimeout.java Wed May 23 17:02:13 2018 +0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -175,9 +175,9 @@
throw new Exception(
"system property timeout configuration does not work");
- } catch (SocketTimeoutException stex) {
+ } catch (SSLException | SocketTimeoutException ex) {
System.out.println("Got expected timeout exception for " +
- "system property timeout configuration: " + stex);
+ "system property timeout configuration: " + getCause(ex));
} finally {
done();
http.disconnect();
@@ -196,9 +196,9 @@
throw new Exception(
"HttpsURLConnection.setReadTimeout() does not work");
- } catch (SocketTimeoutException stex) {
+ } catch (SSLException | SocketTimeoutException ex) {
System.out.println("Got expected timeout exception for " +
- "HttpsURLConnection.setReadTimeout(): " + stex);
+ "HttpsURLConnection.setReadTimeout(): " + getCause(ex));
} finally {
done();
http.disconnect();
@@ -208,6 +208,20 @@
}
}
+ private Exception getCause(Exception ex) {
+ Exception cause = null;
+ if (ex instanceof SSLException) {
+ cause = (Exception) ex.getCause();
+ if (!(cause instanceof SocketTimeoutException)) {
+ throw new RuntimeException("Unexpected cause", cause);
+ }
+ } else {
+ cause = ex;
+ }
+
+ return cause;
+ }
+
static class NameVerifier implements HostnameVerifier {
public boolean verify(String hostname, SSLSession session) {
return true;