Unresponsive proxy with ProxyListFallbackSelector -> NPE
lwahonen opened this issue · comments
How to reproduce:
- Set up a SOCKS proxy set in IE proxy.pac. This doesn't happen if SOCKS proxy is supplied with -DsocksProxyHost parameter on JVM command line, as that results in an ProtocolDispatchSelector instead of ProxyListFallbackSelector
- Take down network connectivity to that proxy (e.g. don't start ssh -D )
- Make two http requests
Expected result: Network fails with IOException, which applications expect and usually know how to deal with
Actual result: ProxyListFallbackSelector clears the proxy list on first http request, second request gets an NPE somewhere deep in sun.net.www...
Ok. I think I found it. From the JavaDoc of ProxySelector.select(URI uri)
:
@return
a List of Proxies. Each element in the the List is of type java.net.Proxy Proxy
; when no proxy is available, the list will contain one element of type java.net.Proxy Proxy
that represents a direct connection.
In your scenario ProxyListFallbackSelector
will return an empty list on the second call. This is against the spec.
Will add a Proxy.NO_PROXY
in that case to the list.
Added a fix and unit test
Will be in the upcoming release