okhttp: IllegalStateException when reading data from a connection closed by another thread
The log shows my REST reader getting an IllegalStateException when trying to read from an HTTP connection that has been closed (not by me). I think it should throw an IOException instead. This is with the okhttp 2.0 master branch.
java.lang.IllegalStateException: closed
at okio.RealBufferedSink.flush(SourceFile:152)
at com.squareup.okhttp.internal.http.HttpEngine.readResponse(SourceFile:570)
at com.squareup.okhttp.internal.http.HttpURLConnectionImpl.execute(SourceFile:384)
at com.squareup.okhttp.internal.http.HttpURLConnectionImpl.getResponse(SourceFile:331)
at com.squareup.okhttp.internal.http.HttpURLConnectionImpl.getHeaderFields(SourceFile:178)
at com.squareup.okhttp.internal.http.DelegatingHttpsURLConnection.getHeaderFields(SourceFile:178)
at com.squareup.okhttp.internal.http.HttpsURLConnectionImpl.getHeaderFields(SourceFile:1)
at com.levelup.touiteur.DBCookieMaster.setCookieResponse(SourceFile:460)
at com.levelup.http.AbstractHttpRequest.setResponse(SourceFile:159)
at com.levelup.http.twitter.HttpTwitterPost.setResponse(SourceFile:66)
at com.levelup.http.HttpClient.getQueryResponse(SourceFile:165)
at com.levelup.http.HttpClient.getInputStream(SourceFile:187)
at com.levelup.http.HttpClient.parseRequest(SourceFile:274)
at com.levelup.http.HttpClient.getStringResponse(SourceFile:312)
at com.levelup.http.twitter.TwitterOAuth.getRequestTokener(SourceFile:165)
at com.levelup.http.twitter.TwitterOAuth.queryJSONObject(SourceFile:72)
at com.levelup.http.twitter.TwitterOAuth.queryJSONObjectOnly(SourceFile:68)
at com.plume.twitter.TwitterClient.queryJSONObjectOnly(SourceFile:641)
at com.plume.twitter.TwitterClient$ProfileUpdateBuilder.updateProfile(SourceFile:1070)
at com.levelup.touiteur.ProfileTwitter$2$1.execute(SourceFile:554)
at com.levelup.touiteur.ActivityTouiteur$BusyWorkingThread.run(SourceFile:595)```
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 18 (11 by maintainers)
Commits related to this issue
- More https://github.com/square/okhttp/issues/689 catching — committed to levelup/Android-HttpClient by robUx4 10 years ago
Hello, OkHttp 2.2.0
When i use
there is exception like this (for
String ceyson = response.body().string();
)But when i use only
String ceyson = response.body().string();
it is ok