core: handle empty proxy selector result#12793
Conversation
|
|
b6066e0 to
da37275
Compare
da37275 to
ac43fae
Compare
|
Hi @ejona86, would you be the right person to review this small proxy detection fix? |
|
Can we identify the broken Android deployments? I know we can't fix them, but we can document what software we are working around. The Java API says there will always be entries in the list, so both null and empty list are invalid. I'd normally suggest we fail (cleanly, not like it is now) instead of ignoring the API breakage. |
Thanks for the context. |
|
So I've looked around some, and I don't see any other reports of something like this. I'm very suspicious, as Android 14 is plenty old enough for us to have heard of this problem. It is seeming more likely at this point that maybe you have a broken ProxySelector configured somewhere in your app. How does this sound: Add in checks for null/isEmpty(), and throw an IOException with the classname of the ProxySelector as part of the error string. I know exception strings are often discarded on Android, but this has no semantic concerns and would help anyone that accidentally writes a broken ProxySelector. Ideally the ProxySelector would get fixed, instead of all callers working around it. If we find out this behavior is widespread we would re-evaluate the approach. |
Fixes a crash in
ProxyDetectorImplwhenProxySelector.select(URI)returns an empty list.On some Android devices/configurations,
ProxySelector.select(uri)can returnCollections.emptyList().ProxyDetectorImplpreviously assumed the returned listalways contained at least one element and called proxies.get(0), causing:
This change treats null/empty proxy selector results as "no proxy" and proceeds
without proxy, matching the behavior for
Proxy.Type.DIRECT.Added a unit test covering an empty proxy list.