Repository navigation
core: Handle ProxySelector IllegalArgumentException - #13053
Conversation
|
|
|
Thanks for picking this up. Approach is right, a few things need changing. The test doesn't cover the actual bug. Related: Also worth knowing: the message you're building never reaches the user, because |
| IOException exception = | ||
| assertThrows(IOException.class, () -> proxyDetector.proxyFor(destination)); | ||
|
|
||
| assertEquals(cause, exception.getCause()); |
There was a problem hiding this comment.
Nit: assertSame for the cause.
There was a problem hiding this comment.
Thanks for taking a close look. This is helpful. I agree that a resolver level test would better cover the actual failure path, and I will change the cause check to assertSame.
Before I rework the implementation, could one of the maintainers confirm the preferred behavior? Should this fall back to a direct connection, or return UNAVAILABLE? Also, should the broader RuntimeException handling be placed around detectProxy() in DnsNameResolver?
Once that is confirmed, I will update the implementation.
There was a problem hiding this comment.
Hi @ejona86 , I wanted to follow up on the behavior decision for this PR. Should a RuntimeException from detectProxy() fall back to a direct connection, or should it return UNAVAILABLE? Once the preferred behavior is confirmed, I can add the DnsNameResolver regression test and update the exception handling accordingly. Thank you.
Fixes #13052.
Android’s DefaultProxySelector.select() can throw IllegalArgumentException when a configured proxy port is invalid, causing an unchecked exception to escape the DNS resolver task.
This change wraps that exception in an IOException with the message "Failed when selecting a proxy", preserving the original cause. The resolver’s existing error handling reports UNAVAILABLE.
Testing