Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Unexpected Hostname Causing Crash in Android

Open
#9,758 0 comments 4 reactions 0 assignees View on GitHub

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
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
android, java, kotlin
Domain
backend

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

bug

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lysine-dev/okhttp

All issues in lysine-dev/okhttp

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.