Skip to content

Release unsent LastHttpContent in HttpChunkedInput (#17240) - #17252

Merged
normanmaurer merged 1 commit into
5.0from
chunk_5
Aug 11, 2026
Merged

normanmaurer merged 1 commit into
5.0from
chunk_5

Conversation

@normanmaurer

Copy link
Copy Markdown
Member

Motivation:

HttpChunkedInput retains a custom LastHttpContent until
readChunk(...)
returns it. If ChunkedWriteHandler discards a suspended or otherwise
incomplete write, it closes the HttpChunkedInput, but the previous
implementation only closed the wrapped input. The unsent terminating
content
therefore remained at refCnt == 1.

Modification:

  • Release the terminating content from HttpChunkedInput.close() when
    it has
    not been handed off by readChunk(...).
  • Perform that release in a finally block so a wrapped input close
    failure
    cannot leak the content.
  • Mark the terminal state before releasing so repeated close() calls
    cannot
    double-release it.
  • Document ownership of a custom terminating content.
  • Add tests for an aborted ChunkedWriteHandler write, the successful
    handoff
    path, a wrapped input close failure, and repeated close calls.

Result:

Custom terminating content is released when a chunked HTTP write is
closed
before completion, while successfully handed-off content remains owned
by the
outbound pipeline.

Testing:

  • ./mvnw -q -pl codec-http -Dtest=HttpChunkedInputTest test
  • ./mvnw -q -Pleak -pl codec-http -Dtest=HttpChunkedInputTest test
  • ./mvnw -q -pl codec-http -am -DskipTests install

Motivation:

`HttpChunkedInput` retains a custom `LastHttpContent` until
`readChunk(...)`
returns it. If `ChunkedWriteHandler` discards a suspended or otherwise
incomplete write, it closes the `HttpChunkedInput`, but the previous
implementation only closed the wrapped input. The unsent terminating
content
therefore remained at `refCnt == 1`.

Modification:

- Release the terminating content from `HttpChunkedInput.close()` when
it has
  not been handed off by `readChunk(...)`.
- Perform that release in a `finally` block so a wrapped input close
failure
  cannot leak the content.
- Mark the terminal state before releasing so repeated `close()` calls
cannot
  double-release it.
- Document ownership of a custom terminating content.
- Add tests for an aborted `ChunkedWriteHandler` write, the successful
handoff
  path, a wrapped input close failure, and repeated close calls.

Result:

Custom terminating content is released when a chunked HTTP write is
closed
before completion, while successfully handed-off content remains owned
by the
outbound pipeline.

Testing:

- `./mvnw -q -pl codec-http -Dtest=HttpChunkedInputTest test`
- `./mvnw -q -Pleak -pl codec-http -Dtest=HttpChunkedInputTest test`
- `./mvnw -q -pl codec-http -am -DskipTests install`
@normanmaurer normanmaurer added this to the 5.0.0.Final milestone Aug 10, 2026
@testlens-app

testlens-app Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

🚨 TestLens detected 2 failed tests 🚨

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 / windows-x86_64-java25-boringssl > Netty/Build/Jextract Maven Plugin

Test Runs Flakiness
JextractLocatorTest > throwsWhenExplicitPathIsNotExecutable() ❌ 0% 🟢
JextractLocatorTest > throwsWhenJextractEnvIsNotExecutable() ❌ 0% 🟢

🏷️ Commit: dab5cb0
▶️ Tests: 229047 executed
⚪️ Checks: 12/12 completed

Test Failures

JextractLocatorTest > throwsWhenExplicitPathIsNotExecutable() (Netty/Build/Jextract Maven Plugin in Build PR / windows-x86_64-java25-boringssl)
org.opentest4j.AssertionFailedError: expected: <true> but was: <false>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
	at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
	at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
	at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:31)
	at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:183)
	at io.netty.build.jextract.JextractLocatorTest.throwsWhenExplicitPathIsNotExecutable(JextractLocatorTest.java:113)
	at java.base/java.lang.reflect.Method.invoke(Method.java:565)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
expected actual
true false
JextractLocatorTest > throwsWhenJextractEnvIsNotExecutable() (Netty/Build/Jextract Maven Plugin in Build PR / windows-x86_64-java25-boringssl)
org.opentest4j.AssertionFailedError: expected: <true> but was: <false>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
	at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
	at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
	at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:31)
	at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:183)
	at io.netty.build.jextract.JextractLocatorTest.throwsWhenJextractEnvIsNotExecutable(JextractLocatorTest.java:127)
	at java.base/java.lang.reflect.Method.invoke(Method.java:565)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
expected actual
true false

Muted Tests

Select tests to mute in this pull request:

  • JextractLocatorTest > throwsWhenExplicitPathIsNotExecutable()
  • JextractLocatorTest > throwsWhenJextractEnvIsNotExecutable()

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.

@normanmaurer
normanmaurer merged commit ea847ee into 5.0 Aug 11, 2026
12 of 13 checks passed
@normanmaurer
normanmaurer deleted the chunk_5 branch August 11, 2026 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants