Summary
HttpURLConnection falls back to a direct connection if the first proxy connection attempt fails. This behaviour is seen with Oracle JDK8u and Oracle JDK7u and is a bug.
Problem
The HttpURLConnection
implementation of java.net.URLConnection::connect
falls back to trying a direct connection when a proxy has been configured but the connection attempt to the proxy fails. This should not be the case.
This behaviour has been fixed from JDK9 onwards, and this is a backport request to Oracle JDK8u and Oracle JDK7u.
Solution
The HttpURLConnection
implementation of java.net.URLConnection::connect
has been updated so that
when a proxy is configured but the connection attempt to the proxy fails, there is a single connection retry to the same proxy ( rather than a direct connection ).
The solution that is being proposed here is a combination of two issues, that results in the same behaviour as that of JDK11 (and subsequent releases). More specifically, JIRA issues JDK-8161016 and JDK-8183369. (The proposal is to backport the changes for both JDK-8161016 and JDK-8183369, since they are inherently related)
Given the change in behaviour being proposed here, and the maturity of Oracle JDK 8u and Oracle JDK 7u, a new system property sun.net.http.fallbackToDirect
is introduced to revert to the old behaviour (fallback to a direct connection if the first proxy connection attempt fails)
Specification
Add a new System Property for HttpURLConnection to fall back to the old functionality.
Name: sun.net.http.fallbackToDirect
Usage: indicates that the HttpURLConnection should fall back to direct connection if the first proxy connection attempt fails.
Value: a boolean, false by default
A release note JDK-8268881 has been added describing this behaviour change and the usage of the system property.
- csr of
-
JDK-8268879 Strange behavior of URLConnection with proxy
-
- Resolved
-