RFR: 8262442 (windows) use all proxy configuration sources when java.net.useSystemProxies=true
Daniel Jeliński
duke at openjdk.java.net
Sun Oct 31 07:47:14 UTC 2021
On Mon, 18 Oct 2021 19:25:12 GMT, Daniel Jeliński <duke at openjdk.java.net> wrote:
> With this patch DefaultProxySelector first attempts to use proxy config autodetection (http://wpad/wpad.dat) when that is configured and available.
> If proxy config autodetection is unavailable, selector tries to use configured proxy script (again, if configured and available)
> If both the above options fail, selector uses the configured proxy.
>
> Verified on Windows 10 that:
> - when `fAutoDetect` is true, http://wpad/wpad.dat refers to an existing file, the file has correct syntax and returns a proxy, that proxy is used
> - when `fAutoDetect` is true, but the autoconfig file is not available / unusable for any reason, selector fails over to the next configured method
> - when `lpszAutoConfigUrl` is set and usable, the proxy returned is used
> - when `lpszAutoConfigUrl` is not set or unusable, selector fails over to next method
> - when `lpszProxy` is configured, that proxy is used
> - otherwise selector uses direct connection
>
> The proxy configuration scripts are cached on system level, so testing (alternating between good and broken autoconfig script) may require waiting for the caches to invalidate.
No automatic tests; to test this manually I used 2 proxy autoconfig files of form:
function FindProxyForURL(url, host) {
if (url.includes("example")) {
return "PROXY 10.4.5.6:8192";
} else {
return "DIRECT";
}
}
one named `wpad.dat`, other named `proxy.pac`, returning different proxy addresses so that I could figure out which one was used. These files were served by a http server running on localhost, conveniently set up with `python -m http.server 80`.
Next, I added the following line to `c:\Windows\System32\drivers\etc\hosts`:
127.0.0.1 wpad
Next, I used the little Java program found in [JDK-8262442](https://bugs.openjdk.java.net/browse/JDK-8262442) to test what ProxySelector returned with different combinations of proxy configuration options.
-------------
PR: https://git.openjdk.java.net/jdk/pull/5995
More information about the net-dev
mailing list