Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalStateException - Http2$Writer.headers #1651

Closed
juliocotta opened this issue May 15, 2015 · 3 comments
Closed

IllegalStateException - Http2$Writer.headers #1651

juliocotta opened this issue May 15, 2015 · 3 comments
Labels
bug Bug in existing code
Milestone

Comments

@juliocotta
Copy link

I found this crash in crashlytics Android 5.0 - XT1097

java.lang.IllegalStateException
       at com.squareup.okhttp.internal.spdy.Http2$Writer.headers(Http2.java:444)
       at com.squareup.okhttp.internal.spdy.Http2$Writer.synStream(Http2.java:410)
       at com.squareup.okhttp.internal.spdy.SpdyConnection.newStream(SpdyConnection.java:266)
       at com.squareup.okhttp.internal.spdy.SpdyConnection.newStream(SpdyConnection.java:242)
       at com.squareup.okhttp.internal.http.SpdyTransport.writeRequestHeaders(SpdyTransport.java:89)
       at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:814)
       at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:684)
       at com.squareup.okhttp.Call.getResponse(Call.java:272)
       at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:228)
       at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:199)
       at com.squareup.okhttp.Call.access$100(Call.java:34)
       at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:162)
       at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
       at java.lang.Thread.run(Thread.java:818)
@swankjesse
Copy link
Collaborator

Are you able to reproduce? Seems impossible!

@swankjesse swankjesse added the bug Bug in existing code label May 17, 2015
@swankjesse swankjesse added this to the 2.5 milestone May 17, 2015
@juliocotta
Copy link
Author

When the error happens (happened 7 times in crashlytics log) I have a lot of threads (100 or more) with the name like "OkHttp https://maps.googleapis.com/maps/api/geocode/json?&latlng=-31.011166%2C-50.188923" with the latlng changing a bit (The app is tracking the user location)...the bunch of requests may be some bug in my code, but the error itself does not seems to be.
Each thread is in the same point when the error happens:

thread
       at libcore.io.Posix.android_getaddrinfo(Posix.java)
       at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:55)
       at java.net.InetAddress.lookupHostByName(InetAddress.java:438)
       at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
       at java.net.InetAddress.getAllByName(InetAddress.java:215)
       at com.squareup.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)
       at com.squareup.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:224)
       at com.squareup.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:193)
       at com.squareup.okhttp.internal.http.RouteSelector.next(RouteSelector.java:113)
       at com.squareup.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:344)
       at com.squareup.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:329)
       at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:319)
       at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:241)
       at com.squareup.okhttp.Call.getResponse(Call.java:271)
       at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:228)
       at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:199)
       at com.squareup.okhttp.Call.access$100(Call.java:34)
       at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:162)
       at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
       at java.lang.Thread.run(Thread.java:818)

@swankjesse
Copy link
Collaborator

I think the problem is that writing headers can throw an IOException, which leaves the socket in an inconsistent state. The fix is to detect this problem and throw IOExceptions when it happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug in existing code
Projects
None yet
Development

No branches or pull requests

2 participants