RFR 8238579: HttpsURLConnection drops the timeout and hangs forever in read
Daniel Fuchs
daniel.fuchs at oracle.com
Fri Feb 14 19:09:34 UTC 2020
Hi Vyom,
On the surface, your patch seems reasonable.
I would be more confident if there was a test, but I understand
it might well be one of these noreg-hard issues.
I've put it on my TODO list to import your patch and
try to test it in our test system.
I'll get back to you when I have managed to find some
cycles to do so.
best regards,
-- daniel
On 14/02/2020 04:57, Vyom Tiwari wrote:
> 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