BufferedSource.readUtf8() causing DataFormatException: invalid distance too far back
See original GitHub issueAfter I updated OkHttp to 4.8.0
, I started receiving this error in the crash reporting tool.
Stack trace:
Non-fatal Exception: java.io.IOException: java.util.zip.DataFormatException: invalid distance too far back
at okio.InflaterSource.readOrInflate(InflaterSource.java:99)
at okio.InflaterSource.read(InflaterSource.java:49)
at okio.GzipSource.read(GzipSource.java:69)
at okio.internal.BufferKt.commonWriteAll(BufferKt.java:1061)
at okio.Buffer.writeAll(Buffer.java:1655)
at okio.internal.RealBufferedSourceKt.commonReadUtf8(RealBufferedSourceKt.java:171)
at okio.RealBufferedSource.readUtf8(RealBufferedSource.java:309)
...
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Example:
inline fun run(result: (Int, BufferedSource) -> Unit) {
val json = JSONObject()
json.put("foo", 123)
val requestBody = json.toString().toRequestBody(JSON)
val request = Request
.Builder()
.url("https://google.com")
.post(requestBody)
.build()
val response = okHttp
.newCall(request)
.execute()
response.body?.run {
if (response.isSuccessful) {
result(response.code, source())
}
close()
}
}
And then:
run { _: Int, bufferedSource: BufferedSource ->
val result = bufferedSource.readUtf8() //Crash here
}
Could be source()
and then calling readUtf8()
be the problem?
The crash happened in a Galaxy Grand Prime Plus
running Android 6.0.1.
Secondary log crash report (can be related):
Non-fatal Exception: java.io.IOException: ID1ID2: actual 0x00000800 != expected 0x00001f8b
at okio.GzipSource.checkEqual(GzipSource.java:197)
at okio.GzipSource.consumeHeader(GzipSource.java:110)
at okio.GzipSource.read(GzipSource.java:62)
at okio.internal.BufferKt.commonWriteAll(BufferKt.java:1061)
at okio.Buffer.writeAll(Buffer.java:1655)
at okio.internal.RealBufferedSourceKt.commonReadUtf8(RealBufferedSourceKt.java:171)
at okio.RealBufferedSource.readUtf8(RealBufferedSource.java:309)
...
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
java.util.zip.ZipException: invalid distance too far back while ...
java.util.zip.ZipException: invalid distance too far back while decompressing ; 2. Then the compressed data has been corrupted. – Mark Adler.
Read more >invalid distance too far back" exception for the attached file
PdfBox throws the following exception: Caused by: java.io.IOException: java.util.zip.DataFormatException: invalid distance too far back at ...
Read more >[Samtools-help] invalid distance too far back error for picard ...
Re: [Samtools-help] invalid distance too far back error for picard ... I'm definitely not saying that I know the cause of the >...
Read more >All Strings | PDF | Database Index - Scribd
() V ()[ (+%-4d) [%2d] %s (2)Error querying user properties (2)Read invalid user property value, ignoring it (2)Too many active user properties, ignoring...
Read more >Corrupted Jar File Causes "java.util.zip.ZipException
Oracle WebLogic Server - Version 12.2.1.2.0 and later: Corrupted Jar File Causes "java.util.zip.ZipException: invalid distance too far back"
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://stackoverflow.com/questions/57518909/why-do-kotlin-files-appear-as-java-is-fabric-crashlytics-with-proguard-enabled
A web search for the exception suggests the server is not returning well-formed gzip data. You should request the server’s administrators fix the problem.
In the interim you can disable compression with this request header: