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

java.io.IOException: gzip finished without exhausting source #1170

Closed
BillBosiolis opened this issue Oct 6, 2015 · 6 comments
Closed

java.io.IOException: gzip finished without exhausting source #1170

BillBosiolis opened this issue Oct 6, 2015 · 6 comments

Comments

@BillBosiolis
Copy link

Hi,

I am using Retrofit (2.0.0-beta2) in an Android application to consume a REST service written in PHP. All the responses are gzipped. Also, I am using a GsonConverter to convert the response to java objects.

In some cases, OKio throws an exception like the one seen below

10-06 19:06:28.092 26062-26085/? W/System.err: java.io.IOException: gzip finished without exhausting source
10-06 19:06:28.092 26062-26085/? W/System.err:     at okio.GzipSource.read(GzipSource.java:100)
10-06 19:06:28.093 26062-26085/? W/System.err:     at okio.RealBufferedSource.read(RealBufferedSource.java:50)
10-06 19:06:28.093 26062-26085/? W/System.err:     at okio.ForwardingSource.read(ForwardingSource.java:35)
10-06 19:06:28.093 26062-26085/? W/System.err:     at retrofit.OkHttpCall$ExceptionCatchingRequestBody$1.read(OkHttpCall.java:220)
10-06 19:06:28.093 26062-26085/? W/System.err:     at okio.RealBufferedSource$1.read(RealBufferedSource.java:371)
10-06 19:06:28.094 26062-26085/? W/System.err:     at java.io.InputStreamReader.read(InputStreamReader.java:231)
10-06 19:06:28.094 26062-26085/? W/System.err:     at com.google.gson.stream.JsonReader.fillBuffer(JsonReader.java:1300)
10-06 19:06:28.094 26062-26085/? W/System.err:     at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:1346)
10-06 19:06:28.094 26062-26085/? W/System.err:     at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:542)
10-06 19:06:28.094 26062-26085/? W/System.err:     at com.google.gson.stream.JsonReader.peek(JsonReader.java:429)
10-06 19:06:28.094 26062-26085/? W/System.err:     at com.google.gson.Gson.assertFullConsumption(Gson.java:782)
10-06 19:06:28.094 26062-26085/? W/System.err:     at com.google.gson.Gson.fromJson(Gson.java:776)
10-06 19:06:28.094 26062-26085/? W/System.err:     at retrofit.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:36)
10-06 19:06:28.094 26062-26085/? W/System.err:     at retrofit.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:24)
10-06 19:06:28.094 26062-26085/? W/System.err:     at retrofit.OkHttpCall.parseResponse(OkHttpCall.java:148)
10-06 19:06:28.094 26062-26085/? W/System.err:     at retrofit.OkHttpCall.execute(OkHttpCall.java:116)
10-06 19:06:28.094 26062-26085/? W/System.err:     at retrofit.ExecutorCallAdapterFactory$ExecutorCallbackCall.execute(ExecutorCallAdapterFactory.java:61)
10-06 19:06:28.094 26062-26085/? W/System.err:     at com.example.android.retrofit2.MainActivity$MyTask.doInBackground(MainActivity.java:75)
10-06 19:06:28.094 26062-26085/? W/System.err:     at com.example.android.retrofit2.MainActivity$MyTask.doInBackground(MainActivity.java:63)
10-06 19:06:28.094 26062-26085/? W/System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:292)
10-06 19:06:28.094 26062-26085/? W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
10-06 19:06:28.094 26062-26085/? W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
10-06 19:06:28.094 26062-26085/? W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
10-06 19:06:28.094 26062-26085/? W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
10-06 19:06:28.094 26062-26085/? W/System.err:     at java.lang.Thread.run(Thread.java:818)

A response example can be seen below (taken from Fiddler)

HTTP/1.1 200 OK
Date: Tue, 06 Oct 2015 23:40:22 GMT
Server: Apache/2.4.16
Vary: Accept-Encoding
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
Content-Length: 60020

{"teams":[{"id":"2408","name":"Panionios","logo":"984.png"},{"id":"2416","name":"Birmingham","logo":"609.png"},{"id":"2417","name":"Blackburn ","logo":"612.png"},{"id":"2418","name":"Bolton","logo":"614.png"},{"id":"2419","name":"Charlton","logo":"628.png"},{"id":"2420","name":"Chelsea","logo":"630.png"},{"id":"2422","name":"Fulham","logo":"654.png"},{"id":"2427","name":"Manchester Utd","logo":"680.png"},{"id":"2428","name":"Middlesbrough","logo":"685.png"},{"id":"2432","name":"Tottenham","logo":"728.png"}]}

Any help would be appreciated.

Thanks,
Bill

@JakeWharton
Copy link
Member

Do you have access to the raw response? The example you pasted is (obviously) not gzipped, and it's going to be hard to reproduce what's happening here without the exact data.

I'm still going to give it a quick shot, but I can only guess as to the behavior you're seeing which isn't all that useful.

@BillBosiolis
Copy link
Author

Thanks @JakeWharton

Is it OK if I send you the details privately?

@JakeWharton
Copy link
Member

Sure! You can email me at jakewharton@gmail.com.

@BillBosiolis
Copy link
Author

OK. This one can be closed. It has nothing to do with retrofit/OkHttp.

In fact, it seems that the problem was that the server code (not Apache) was always sending a Content-Length header back even in cases where chunked encoding was being used.

@nakisgeo
Copy link

Hi Bill,

I have to same error in one of my application. Can you tell me how you fixed it ?

@yzgt
Copy link

yzgt commented Jun 6, 2022

这个问题解决了吗?我也遇到了

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

No branches or pull requests

4 participants