Skip to content

Don't close the multipart sink when a part closes its stream - #9659

Open
iVamsi wants to merge 4 commits into
lysine-dev:mainfrom
iVamsi:fix/gzip-multipart-closed-7692
Open

Don't close the multipart sink when a part closes its stream#9659
iVamsi wants to merge 4 commits into
lysine-dev:mainfrom
iVamsi:fix/gzip-multipart-closed-7692

Conversation

@iVamsi

@iVamsi iVamsi commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

A request body closing its sink was also closing the stream that OkHttp was still writing to. In a multipart request, that meant the next part (or even the bytes after the first part) failed with IllegalStateException: closed.

The part still needs to finish its stream. This change lets it do that without closing the stream MultipartBody was handed.

Fixes #7692.

@JakeWharton

Copy link
Copy Markdown
Collaborator

This seems like it fixes a very specific variant of this bug, but not the whole class of bug.

@iVamsi iVamsi changed the title Don't close the stream when gzipping a request body Don't close the multipart sink when a part closes its stream Aug 13, 2026
@iVamsi

iVamsi commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

@JakeWharton Yeah, gzip was just one body that closed the sink. Moved the fix to MultipartBody.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants