Unexpected Hostname Causing Crash in Android
Maintainers usually reply within 1 day
Nobody has claimed this yet.
- #9773 by @omers-oai — closed without merging
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 35/100
Research direction
Start with the reported Dns.Request and RouteSelector.dnsLookup stack frames, then inspect the malformed-proxy regression test shown in the issue and related proxy tests. Run the focused test; done means a proxy hostname with trailing whitespace fails the request with an IOException rather than crashing the dispatcher thread.
Written by the indexing model from the issue text.
Description
After upgrading to OkHttp 5.5.0 we got this crash report in our app
Fatal Exception: java.lang.IllegalArgumentException: unexpected hostname: internet.africell.co ao
at okhttp3.Dns$Request.<init>(Dns.kt:115)
at okhttp3.internal.connection.RouteSelector.dnsLookup(RouteSelector.java:224)
at okhttp3.internal.connection.RouteSelector.nextRoutes(RouteSelector.java:184)
at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.java:140)
at okhttp3.internal.connection.RouteSelector.next(RouteSelector.java:72)
at okhttp3.internal.connection.RealRoutePlanner.planConnect$okhttp(RealRoutePlanner.kt:170)
at okhttp3.internal.connection.RealRoutePlanner.plan(RealRoutePlanner.kt:77)
at okhttp3.internal.connection.FastFallbackExchangeFinder.launchTcpConnect(FastFallbackExchangeFinder.java:122)
at okhttp3.internal.connection.FastFallbackExchangeFinder.find(FastFallbackExchangeFinder.java:64)
at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.java:306)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:32)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:332)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:98)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:332)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:83)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:332)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:72)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:332)
at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:234)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:582)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1100)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:1572)
It's a valid IllegalStateException but I don't think it should crash the app.
Some test that might help:
/**
* A malformed system proxy, such as a carrier APN proxy whose host has a trailing space, must
* fail the request with an [IOException]. Before that it crashed the dispatcher thread with an
* unchecked [IllegalArgumentException] from `Dns.Request`.
*/
@Test
fun malformedProxyHostnameFailsGracefully() {
val proxySelector = RecordingProxySelector()
proxySelector.proxies.add(
Proxy(Proxy.Type.HTTP, InetSocketAddress.createUnresolved("internet ", 8080)),
)
client = client.newBuilder().proxySelector(proxySelector).build()
executeSynchronously(server.url("/").toString())
.assertFailure(UnknownHostException::class.java)
}
- Dominant language
- Kotlin
- Stars
- 47.1k
- Forks
- 9.3k
- Avg merge
- 18h 18m
- Merged PRs (30d)
- 15
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lysine-dev/okhttp
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
lysine-dev/okhttp#9788 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
lysine-dev/okhttp#9761 · 3 comments ·
Maintainers usually reply within 1 day
-
Remove crossinline `addInterceptor` and `addNetworkInterceptor` overloadsPossibly taken @Amir-Golmoradi claimed this 5 days ago. Openenhancement
Difficulty 3/5 1-2 days Newbie friendliness 58/100
lysine-dev/okhttp#9779 · 1 comment ·
Maintainers usually reply within 1 day
-
HTTP/2 Data padding is not counted toward the connection flow-control window. This deadlocks connections with peers that pad.Possibly taken @Amir-Golmoradi claimed this 5 days ago. Openbug
Difficulty 3/5 1-2 days Newbie friendliness 67/100
lysine-dev/okhttp#9772 · 4 comments ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
lysine-dev/okhttp#9760 · 3 comments ·
Maintainers usually reply within 1 day
All issues in lysine-dev/okhttp
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
rustyrazorblade/easy-db-lab#1017 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
callstack/react-native-brownfield#492 · 1 comment ·
Maintainers usually reply within 4 days
-
fix: retain the best partial noise-correction solutionPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
world-federation-of-advertisers/cross-media-measurement#4653 ·
Maintainers usually reply within 1 day