Repository navigation
Auto-port 4.1: HTTP/2: Release compressors after failed headers writes - #17265
Merged
Merged
Conversation
### Motivation `CompressorHttp2ConnectionEncoder` creates an `EmbeddedChannel` before delegating a HEADERS write. A delegate may fail the promise without throwing and without creating a stream, for example when a client writes headers with an invalid even stream ID. In that case, the compressor is never attached to a stream and is not released by `onStreamRemoved`. A compressor can also be left open if the delegate throws after compressor creation, or if target content encoding preparation fails. ### Modification - Keep ownership of newly created compressors until they are attached to a stream. - Release compressors that are not attached after either `writeHeaders` overload returns or throws. - Release partially initialized compressors if header preparation fails. - Add regression tests for both overloads covering missing streams, synchronous and asynchronous failures, and existing streams in invalid states. ### Result Failed HEADERS writes no longer leave compression `EmbeddedChannel`s open, while compressors attached to streams continue to be released by the existing stream-removal path. ### Testing - `./mvnw -pl codec-http2 -Dtest=CompressorHttp2ConnectionEncoderTest test` - `./mvnw -pl codec-http2 -Dtest=CompressorHttp2ConnectionEncoderTest,DataCompressionHttp2Test test` - `./mvnw -pl codec-http2 test` (cherry picked from commit c797c2f)
✅ All tests passed ✅🏷️ Commit: 07072b0 Learn more about TestLens at testlens.app. |
lltopk
pushed a commit
to lltopk/netty
that referenced
this pull request
Oct 24, 2026
netty#17265) Auto-port of netty#17253 to 4.1 Cherry-picked commit: c797c2f --- ### Motivation `CompressorHttp2ConnectionEncoder` creates an `EmbeddedChannel` before delegating a HEADERS write. A delegate may fail the promise without throwing and without creating a stream, for example when a client writes headers with an invalid even stream ID. In that case, the compressor is never attached to a stream and is not released by `onStreamRemoved`. A compressor can also be left open if the delegate throws after compressor creation, or if target content encoding preparation fails. ### Modification - Keep ownership of newly created compressors until they are attached to a stream. - Release compressors that are not attached after either `writeHeaders` overload returns or throws. - Release partially initialized compressors if header preparation fails. - Add regression tests for both overloads covering missing streams, synchronous and asynchronous failures, and existing streams in invalid states. ### Result Failed HEADERS writes no longer leave compression `EmbeddedChannel`s open, while compressors attached to streams continue to be released by the existing stream-removal path. ### Testing - `./mvnw -pl codec-http2 -Dtest=CompressorHttp2ConnectionEncoderTest test` - `./mvnw -pl codec-http2 -Dtest=CompressorHttp2ConnectionEncoderTest,DataCompressionHttp2Test test` - `./mvnw -pl codec-http2 test` Co-authored-by: Gimin Kim <[email protected]>
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.
Auto-port of #17253 to 4.1
Cherry-picked commit: c797c2f
Motivation
CompressorHttp2ConnectionEncodercreates anEmbeddedChannelbefore delegating a HEADERS write. A delegate may fail the promise without throwing and without creating a stream, for example when a client writes headers with an invalid even stream ID. In that case, the compressor is never attached to a stream and is not released byonStreamRemoved.A compressor can also be left open if the delegate throws after compressor creation, or if target content encoding preparation fails.
Modification
writeHeadersoverload returns or throws.Result
Failed HEADERS writes no longer leave compression
EmbeddedChannels open, while compressors attached to streams continue to be released by the existing stream-removal path.Testing
./mvnw -pl codec-http2 -Dtest=CompressorHttp2ConnectionEncoderTest test./mvnw -pl codec-http2 -Dtest=CompressorHttp2ConnectionEncoderTest,DataCompressionHttp2Test test./mvnw -pl codec-http2 test