RFR 8238579: HttpsURLConnection drops the timeout and hangs forever in read

Vyom Tiwari vyommani at gmail.com
Fri Feb 14 04:57:35 UTC 2020


Hi All,

Please find the below fix  which resolves the issue(
https://bugs.openjdk.java.net/browse/JDK-8238579).

"HttpURLConnection.writeRequests()" retry in case of any write failure,
during retry it creates new HttpsClient  without connectTimeout &
readTimeout. Below fix sets the connect & read timeout.

Thanks,
Vyom

diff -r 7e6165c9c606
src/java.base/share/classes/sun/net/www/protocol/https/AbstractDelegateHttpsURLConnection.java
---
a/src/java.base/share/classes/sun/net/www/protocol/https/AbstractDelegateHttpsURLConnection.java
Thu Feb 13 17:14:45 2020 -0800
+++
b/src/java.base/share/classes/sun/net/www/protocol/https/AbstractDelegateHttpsURLConnection.java
Fri Feb 14 10:11:06 2020 +0530
@@ -87,10 +87,15 @@
      */
     public void setNewClient (URL url, boolean useCache)
         throws IOException {
+        int readTimeout = getReadTimeout();
         http = HttpsClient.New (getSSLSocketFactory(),
                                 url,
                                 getHostnameVerifier(),
-                                useCache, this);
+ null,
+ -1,
+                                useCache,
+ getConnectTimeout(), this);
+ http.setReadTimeout(readTimeout);
         ((HttpsClient)http).afterConnect();
     }

@@ -132,10 +137,14 @@
             boolean useCache) throws IOException {
         if (connected)
             return;
-        http = HttpsClient.New (getSSLSocketFactory(),
-                                url,
-                                getHostnameVerifier(),
-                                proxyHost, proxyPort, useCache, this);
+        int readTimeout = getReadTimeout();
+        http = HttpsClient.New(getSSLSocketFactory(),
+                url,
+                getHostnameVerifier(),
+                proxyHost, proxyPort,
+                useCache,
+                getConnectTimeout(), this);
+        http.setReadTimeout(readTimeout);
         connected = true;
     }


More information about the core-libs-dev mailing list