Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Unexpected Hostname Causing Crash in Android

Aperta
#9,758 0 commenti 4 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

  • #9773 di @omers-oai — chiusa senza merge

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
android, java, kotlin
Ambito
backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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)
}
Lingua principale
Kotlin
Stelle
47.1k
Fork
9.3k
Merge medio
18h 18m
PR unite (30g)
15

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di lysine-dev/okhttp

Tutte le issue di lysine-dev/okhttp

Issue simili

Altre issue su Kotlin

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.