Repository navigation
HTTP: Release content encoder after header mutation failure - #17292
Merged
normanmaurer merged 1 commit intoAug 15, 2026
Merged
Conversation
Gimini-3
marked this pull request as ready for review
August 15, 2026 08:17
✅ All tests passed ✅🏷️ Commit: 95c4774 Learn more about TestLens at testlens.app. |
normanmaurer
approved these changes
Aug 15, 2026
Contributor
|
Auto-port PR for 5.0: #17293 |
Contributor
|
Auto-port PR for 4.1: #17294 |
normanmaurer
added a commit
that referenced
this pull request
Aug 16, 2026
…ilure (#17293) Auto-port of #17292 to 5.0 Cherry-picked commit: 039add4 --- ### Motivation `HttpContentEncoder` stored the `EmbeddedChannel` returned by `beginEncode()` in its `encoder` field before mutating the response headers. If a mutation failed, for example because the response used `ReadOnlyHttpHeaders`, the newly created content encoder remained open. With assertions disabled, a subsequent response could overwrite the field. Handler removal or channel shutdown would then release only the replacement encoder, leaving the first encoder without deterministic cleanup. ### Modification - Keep a newly created content encoder locally owned while response headers and streaming state are prepared. - Transfer ownership to the handler field only when encoding can proceed. - Call `finishAndReleaseAll()` when preparation or synchronous full-response encoding fails before ownership is retained. - Add a regression test that verifies the failed encoder is closed and the handler remains usable for the next response. ### Result Header mutation failures no longer leave a content encoder open or allow it to be lost on a later response. Successful full and streaming response encoding remains unchanged. ### Testing - `./mvnw -pl codec-http -Dtest=HttpContentEncoderTest#testHeaderMutationFailureReleasesContentEncoder test` - `./mvnw -pl codec-http -Dtest=HttpContentEncoderTest#testHeaderMutationFailureReleasesContentEncoder -DargLine.common=-da test` - `./mvnw -pl codec-http test` — 8,983 tests, 0 failures, 0 errors, 4 skipped --------- Co-authored-by: Gimin Kim <[email protected]> Co-authored-by: Norman Maurer <[email protected]>
normanmaurer
added a commit
that referenced
this pull request
Aug 17, 2026
…ilure (#17294) Auto-port of #17292 to 4.1 Cherry-picked commit: 039add4 --- ### Motivation `HttpContentEncoder` stored the `EmbeddedChannel` returned by `beginEncode()` in its `encoder` field before mutating the response headers. If a mutation failed, for example because the response used `ReadOnlyHttpHeaders`, the newly created content encoder remained open. With assertions disabled, a subsequent response could overwrite the field. Handler removal or channel shutdown would then release only the replacement encoder, leaving the first encoder without deterministic cleanup. ### Modification - Keep a newly created content encoder locally owned while response headers and streaming state are prepared. - Transfer ownership to the handler field only when encoding can proceed. - Call `finishAndReleaseAll()` when preparation or synchronous full-response encoding fails before ownership is retained. - Add a regression test that verifies the failed encoder is closed and the handler remains usable for the next response. ### Result Header mutation failures no longer leave a content encoder open or allow it to be lost on a later response. Successful full and streaming response encoding remains unchanged. ### Testing - `./mvnw -pl codec-http -Dtest=HttpContentEncoderTest#testHeaderMutationFailureReleasesContentEncoder test` - `./mvnw -pl codec-http -Dtest=HttpContentEncoderTest#testHeaderMutationFailureReleasesContentEncoder -DargLine.common=-da test` - `./mvnw -pl codec-http test` — 8,983 tests, 0 failures, 0 errors, 4 skipped --------- Co-authored-by: Gimin Kim <[email protected]> Co-authored-by: Norman Maurer <[email protected]>
2 of 11 tasks
Closed
lltopk
pushed a commit
to lltopk/netty
that referenced
this pull request
Oct 24, 2026
…ilure (netty#17294) Auto-port of netty#17292 to 4.1 Cherry-picked commit: 039add4 --- ### Motivation `HttpContentEncoder` stored the `EmbeddedChannel` returned by `beginEncode()` in its `encoder` field before mutating the response headers. If a mutation failed, for example because the response used `ReadOnlyHttpHeaders`, the newly created content encoder remained open. With assertions disabled, a subsequent response could overwrite the field. Handler removal or channel shutdown would then release only the replacement encoder, leaving the first encoder without deterministic cleanup. ### Modification - Keep a newly created content encoder locally owned while response headers and streaming state are prepared. - Transfer ownership to the handler field only when encoding can proceed. - Call `finishAndReleaseAll()` when preparation or synchronous full-response encoding fails before ownership is retained. - Add a regression test that verifies the failed encoder is closed and the handler remains usable for the next response. ### Result Header mutation failures no longer leave a content encoder open or allow it to be lost on a later response. Successful full and streaming response encoding remains unchanged. ### Testing - `./mvnw -pl codec-http -Dtest=HttpContentEncoderTest#testHeaderMutationFailureReleasesContentEncoder test` - `./mvnw -pl codec-http -Dtest=HttpContentEncoderTest#testHeaderMutationFailureReleasesContentEncoder -DargLine.common=-da test` - `./mvnw -pl codec-http test` — 8,983 tests, 0 failures, 0 errors, 4 skipped --------- Co-authored-by: Gimin Kim <[email protected]> Co-authored-by: Norman Maurer <[email protected]>
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
HttpContentEncoderstored theEmbeddedChannelreturned bybeginEncode()in itsencoderfield before mutating the response headers. If a mutation failed, for example because the response usedReadOnlyHttpHeaders, the newly created content encoder remained open.With assertions disabled, a subsequent response could overwrite the field. Handler removal or channel shutdown would then release only the replacement encoder, leaving the first encoder without deterministic cleanup.
Modification
finishAndReleaseAll()when preparation or synchronous full-response encoding fails before ownership is retained.Result
Header mutation failures no longer leave a content encoder open or allow it to be lost on a later response. Successful full and streaming response encoding remains unchanged.
Testing
./mvnw -pl codec-http -Dtest=HttpContentEncoderTest#testHeaderMutationFailureReleasesContentEncoder test./mvnw -pl codec-http -Dtest=HttpContentEncoderTest#testHeaderMutationFailureReleasesContentEncoder -DargLine.common=-da test./mvnw -pl codec-http test— 8,983 tests, 0 failures, 0 errors, 4 skipped