core: Handle ProxySelector IllegalArgumentException - #13053
kkmurthyt21 wants to merge 1 commit into
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.
Fixes #13052.
Android’s
DefaultProxySelector.select()may throwIllegalArgumentExceptionwhen the system proxy configuration contains an invalid port. This unchecked exception currently escapes the DNS resolver task and can terminate the process.This change catches the exception at the
ProxySelector.select()call and wraps it in anIOException. The original cause is preserved, and the exception message identifies theProxySelectorimplementation.DnsNameResolveralready handles anIOExceptionfrom proxy detection as anUNAVAILABLEname-resolution result. This allows the resolver to fail cleanly instead of letting the unchecked exception escape.This intentionally avoids silently falling back to a direct connection. It follows the fail-cleanly approach used for invalid
ProxySelectorresults in #12793 and avoids bypassing a configured proxy.Testing
ProxySelectorimplementation is identified..\gradlew.bat :grpc-core:test --tests "io.grpc.internal.ProxyDetectorImplTest"