Skip to content

okhttp3.RequestBody.Companion#gzip throws java.lang.IllegalStateException: closed if used in MultipartBody #7692

Description

@korniltsev

Reproducer . Tried it on 5.0.0-alpha.11

I believe I can workaround it in our project locally by creating a vendored copy of GzipSink which does not close upstream sink but flushes it with some help of ugly dirty java tricks accessing kotlin internals it should work but it would be nice to be able to use the original extension method in MultipartBody

Stacktrace:

Details Exception in thread "main" java.lang.IllegalStateException: closed at okio.RealBufferedSink.write(RealBufferedSink.kt:176) at okhttp3.MultipartBody.writeOrCountBytes(MultipartBody.kt:162) at okhttp3.MultipartBody.writeTo(MultipartBody.kt:99) at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:64) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:84) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:65) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:205) at okhttp3.internal.connection.RealCall.execute(RealCall.kt:158) at MainKt.main(Main.kt:22)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug in existing code

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions