MarkusBernhardt / proxy-vole

Proxy Vole is a Java library to auto detect the platform network proxy settings.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unresponsive proxy with ProxyListFallbackSelector -> NPE

lwahonen opened this issue · comments

How to reproduce:

  1. 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
  2. Take down network connectivity to that proxy (e.g. don't start ssh -D )
  3. 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