GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — HTTP/2: Release compressors after failed headers writes by Gimini-3 · Pull Request #17253 · netty/netty

Conversation

@Gimini-3

@Gimini-3 Gimini-3 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

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 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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Gimini-3
HTTP/2: Release compressors after failed headers writes
fcae06b
@Gimini-3
Gimini-3 marked this pull request as ready for review August 10, 2026 18:18
normanmaurer
normanmaurer requested changes Aug 11, 2026
View reviewed changes

@normanmaurer normanmaurer left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one comment otherwise LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread codec-http2/src/main/java/io/netty/handler/codec/http2/CompressorHttp2ConnectionEncoder.java Outdated
} else {
headers.set(CONTENT_ENCODING, targetContentEncoding);
}
boolean success = false;

@normanmaurer normanmaurer Aug 11, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider using the same patterns as before (setting compressor to null and only release in finally block when not null)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Gimini-3 Gimini-3 Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use a null compressor as the ownership marker and only release it from the finally block. Thanks.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@normanmaurer normanmaurer added needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. labels Aug 11, 2026
@normanmaurer normanmaurer added this to the 4.2.18.Final milestone Aug 11, 2026
@Gimini-3
HTTP/2: Simplify compressor ownership cleanup
1c16c9b
normanmaurer
normanmaurer approved these changes Aug 11, 2026
View reviewed changes

@normanmaurer normanmaurer left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@testlens-app

testlens-app Bot commented Aug 11, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

🚨 TestLens detected 1 failed test 🚨

Here is what you can do:

  1. Inspect the test failures carefully.
  2. If you are convinced that some of the tests are flaky, you can mute them below.
  3. Finally, trigger a rerun by checking the rerun checkbox.

Test Summary

Build PR / linux-x86_64-java11-boringssl build > Netty/Codec/HTTP2

Test Runs Flakiness
DataCompressionHttp2Test > encodingTooBigMessage(int, AsciiString) > [8] 10, snappy ❌ ✅ 1% 🟡

Build PR / macos-aarch64-java11-boringssl build > Netty/Transport/Native/KQueue

Test Runs Flakiness
KQueueCompositeBufferGatheringWriteTest > testCompositeBufferPartialWriteDoesNotCorruptData(TestInfo) ❌ ✅ 1% 🟡
KQueueCompositeBufferGatheringWriteTest > testSingleCompositeBufferWrite(TestInfo) ❌ ✅ 1% 🟡

Build PR / macos-x86_64-java11-boringssl build > Netty/Transport/Native/KQueue

Test Runs Flakiness
KQueueDatagramUnicastIPv6MappedTest > testSimpleSendCompositeDirectByteBuf(TestInfo) ❌ ✅ 5% 🟠
KQueueDatagramUnicastIPv6MappedTest > testSimpleSendHeapByteBuf(TestInfo) ✅ ❌ 3% 🟡

🏷️ Commit: 1c16c9b
▶️ Tests: 39149 executed
⚪️ Checks: 18/18 completed

Test Failures

KQueueDatagramUnicastIPv6MappedTest > testSimpleSendHeapByteBuf(TestInfo) (Netty/Transport/Native/KQueue in Build PR / macos-x86_64-java11-boringssl build)
org.opentest4j.AssertionFailedError
	at io.netty.testsuite.transport.socket.DatagramUnicastTest.testSimpleSend0(DatagramUnicastTest.java:360)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest.testSimpleSend(DatagramUnicastTest.java:192)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest.testSimpleSendHeapByteBuf(DatagramUnicastTest.java:103)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest$2.run(DatagramUnicastTest.java:97)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest$2.run(DatagramUnicastTest.java:94)
	at io.netty.testsuite.transport.AbstractComboTestsuiteTest.run(AbstractComboTestsuiteTest.java:52)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest.testSimpleSendHeapByteBuf(DatagramUnicastTest.java:94)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)

Muted Tests

Select tests to mute in this pull request:

  • DataCompressionHttp2Test > encodingTooBigMessage(int, AsciiString)
  • KQueueCompositeBufferGatheringWriteTest > testCompositeBufferPartialWriteDoesNotCorruptData(TestInfo)
  • KQueueCompositeBufferGatheringWriteTest > testSingleCompositeBufferWrite(TestInfo)
  • KQueueDatagramUnicastIPv6MappedTest > testSimpleSendCompositeDirectByteBuf(TestInfo)
  • KQueueDatagramUnicastIPv6MappedTest > testSimpleSendHeapByteBuf(TestInfo)

Reuse successful test results:

  • ♻️ Only rerun the tests that failed or were muted before

Click the checkbox to trigger a rerun:

  • Rerun jobs

Learn more about TestLens at testlens.app.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Gimini-3

Gimini-3 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

Could someone with the required permissions please re-run the failed jobs? The macOS failures are in unrelated kqueue tests, and the Linux BoringSSL failure is a timeout in DataCompressionHttp2Test. The related tests pass locally and also passed in the previous CI run. Thanks.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer
normanmaurer merged commit c797c2f into netty:4.2 Aug 11, 2026
31 of 35 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer

normanmaurer commented Aug 11, 2026

Copy link
Copy Markdown
Member

@Gimini-3 thanks a lot!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@netty-project-bot

netty-project-bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Could not create auto-port PR.
Got conflicts when cherry-picking onto 5.0.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer

normanmaurer commented Aug 11, 2026

Copy link
Copy Markdown
Member

Port for 5.0: #17264

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@netty-project-bot netty-project-bot mentioned this pull request Aug 11, 2026
Auto-port 4.1: HTTP/2: Release compressors after failed headers writes #17265
Merged
@netty-project-bot

netty-project-bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Auto-port PR for 4.1: #17265

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. label Aug 11, 2026
normanmaurer pushed a commit that referenced this pull request Aug 12, 2026
@netty-project-bot @Gimini-3
Auto-port 4.1: HTTP/2: Release compressors after failed headers writes (
c1afd14
#17265)

Auto-port of #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]>
normanmaurer added a commit that referenced this pull request Aug 12, 2026
@normanmaurer @Gimini-3
HTTP/2: Release compressors after failed headers writes (#17253) (#17264
b6d8a12
)

`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.

- 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.

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.

- `./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]>
@lhotari lhotari mentioned this pull request Sep 10, 2026
[fix][sec] Upgrade Netty to 4.2.18 to address several CVEs and bugs apache/pulsar#26514
Merged
2 of 11 tasks
@normanmaurer normanmaurer mentioned this pull request Oct 1, 2026
child5 #17695
Closed
@normanmaurer normanmaurer removed the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Oct 16, 2026
lltopk pushed a commit to lltopk/netty that referenced this pull request Oct 24, 2026
@netty-project-bot @Gimini-3 @lltopk
Auto-port 4.1: HTTP/2: Release compressors after failed headers writes (
996c2e4
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]>
@normanmaurer normanmaurer mentioned this pull request Oct 26, 2026
crisp nova cceda091 #18109
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@normanmaurer normanmaurer normanmaurer approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

4.2.18.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@Gimini-3 @normanmaurer @netty-project-bot
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.