Skip to content

Fix flaky HttpToHttp2ConnectionHandlerTest.testChunkedRequestWithBodyAndTrailingHeaders - #17590

Merged
normanmaurer merged 1 commit into
4.2from
h2h_test_fix
Sep 22, 2026
Merged

normanmaurer merged 1 commit into
4.2from
h2h_test_fix

Conversation

@normanmaurer

Copy link
Copy Markdown
Member

Motivation:

HttpToHttp2ConnectionHandlerTest.testChunkedRequestWithBodyAndTrailingHeaders
writes two HttpContent chunks for the same stream and asserted that
exactly one onDataRead(...) call was observed on the server side with
the two payloads concatenated into a single DATA frame. Whether the two
writeData(...) calls get merged into one physical DATA frame by
DefaultHttp2RemoteFlowController's pending-write-queue coalescing is a
timing-dependent internal optimization, not a guarantee of the codec.
When the merge does not happen in time, two separate DATA frames are
delivered instead, which is spec-compliant but failed the test's strict
Mockito verify(times(1)) expectation.

Modifications:

  • Verify onDataRead(...) is invoked atLeastOnce() instead of exactly
    once
  • Assert the concatenation of all received buffers matches the sent
    payload instead of assuming a single buffer

Result:

The test no longer depends on the timing of the flow controller's DATA
frame coalescing and reliably passes regardless of whether the two
chunks are delivered as one or two DATA frames.

Motivation:

HttpToHttp2ConnectionHandlerTest.testChunkedRequestWithBodyAndTrailingHeaders
writes two HttpContent chunks for the same stream and asserted that
exactly one onDataRead(...) call was observed on the server side with
the two payloads concatenated into a single DATA frame. Whether the two
writeData(...) calls get merged into one physical DATA frame by
DefaultHttp2RemoteFlowController's pending-write-queue coalescing is a
timing-dependent internal optimization, not a guarantee of the codec.
When the merge does not happen in time, two separate DATA frames are
delivered instead, which is spec-compliant but failed the test's strict
Mockito verify(times(1)) expectation.

Modifications:

- Verify onDataRead(...) is invoked atLeastOnce() instead of exactly
  once
- Assert the concatenation of all received buffers matches the sent
  payload instead of assuming a single buffer

Result:

The test no longer depends on the timing of the flow controller's DATA
frame coalescing and reliably passes regardless of whether the two
chunks are delivered as one or two DATA frames.
@normanmaurer normanmaurer added this to the 4.2.19.Final milestone Sep 22, 2026
@normanmaurer

Copy link
Copy Markdown
Member Author

Fix for a racy test.

@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 Sep 22, 2026
@normanmaurer normanmaurer changed the title Fix flaky testChunkedRequestWithBodyAndTrailingHeaders assertion Fix flaky HttpToHttp2ConnectionHandlerTest.testChunkedRequestWithBodyAndTrailingHeaders Sep 22, 2026
@testlens-app

testlens-app Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: bb8f304
▶️ Tests: 470516 executed
⚪️ Checks: 30/30 completed


Learn more about TestLens at testlens.app/docs.

@normanmaurer

Copy link
Copy Markdown
Member Author

Let me fix this as it is just a test fix

@normanmaurer
normanmaurer merged commit bb3eb5f into 4.2 Sep 22, 2026
31 checks passed
@normanmaurer
normanmaurer deleted the h2h_test_fix branch September 22, 2026 13:40
@netty-project-bot

Copy link
Copy Markdown
Contributor

Auto-port PR for 5.0: #17592

@github-actions github-actions Bot removed the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Sep 22, 2026
@netty-project-bot

Copy link
Copy Markdown
Contributor

Auto-port PR for 4.1: #17593

@github-actions github-actions Bot removed the needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. label Sep 22, 2026
normanmaurer added a commit that referenced this pull request Sep 22, 2026
…RequestWithBodyAndTrailingHeaders (#17592)

Auto-port of #17590 to 5.0
Cherry-picked commit: bb3eb5f

---
Motivation:


HttpToHttp2ConnectionHandlerTest.testChunkedRequestWithBodyAndTrailingHeaders
writes two HttpContent chunks for the same stream and asserted that
exactly one onDataRead(...) call was observed on the server side with
the two payloads concatenated into a single DATA frame. Whether the two
writeData(...) calls get merged into one physical DATA frame by
DefaultHttp2RemoteFlowController's pending-write-queue coalescing is a
timing-dependent internal optimization, not a guarantee of the codec.
When the merge does not happen in time, two separate DATA frames are
delivered instead, which is spec-compliant but failed the test's strict
Mockito verify(times(1)) expectation.

Modifications:

- Verify onDataRead(...) is invoked atLeastOnce() instead of exactly
  once
- Assert the concatenation of all received buffers matches the sent
  payload instead of assuming a single buffer

Result:

The test no longer depends on the timing of the flow controller's DATA
frame coalescing and reliably passes regardless of whether the two
chunks are delivered as one or two DATA frames.

Co-authored-by: Norman Maurer <[email protected]>
normanmaurer added a commit that referenced this pull request Sep 22, 2026
…RequestWithBodyAndTrailingHeaders (#17593)

Auto-port of #17590 to 4.1
Cherry-picked commit: bb3eb5f

---
Motivation:


HttpToHttp2ConnectionHandlerTest.testChunkedRequestWithBodyAndTrailingHeaders
writes two HttpContent chunks for the same stream and asserted that
exactly one onDataRead(...) call was observed on the server side with
the two payloads concatenated into a single DATA frame. Whether the two
writeData(...) calls get merged into one physical DATA frame by
DefaultHttp2RemoteFlowController's pending-write-queue coalescing is a
timing-dependent internal optimization, not a guarantee of the codec.
When the merge does not happen in time, two separate DATA frames are
delivered instead, which is spec-compliant but failed the test's strict
Mockito verify(times(1)) expectation.

Modifications:

- Verify onDataRead(...) is invoked atLeastOnce() instead of exactly
  once
- Assert the concatenation of all received buffers matches the sent
  payload instead of assuming a single buffer

Result:

The test no longer depends on the timing of the flow controller's DATA
frame coalescing and reliably passes regardless of whether the two
chunks are delivered as one or two DATA frames.

Co-authored-by: Norman Maurer <[email protected]>
lltopk pushed a commit to lltopk/netty that referenced this pull request Oct 24, 2026
…RequestWithBodyAndTrailingHeaders (netty#17593)

Auto-port of netty#17590 to 4.1
Cherry-picked commit: bb3eb5f

---
Motivation:


HttpToHttp2ConnectionHandlerTest.testChunkedRequestWithBodyAndTrailingHeaders
writes two HttpContent chunks for the same stream and asserted that
exactly one onDataRead(...) call was observed on the server side with
the two payloads concatenated into a single DATA frame. Whether the two
writeData(...) calls get merged into one physical DATA frame by
DefaultHttp2RemoteFlowController's pending-write-queue coalescing is a
timing-dependent internal optimization, not a guarantee of the codec.
When the merge does not happen in time, two separate DATA frames are
delivered instead, which is spec-compliant but failed the test's strict
Mockito verify(times(1)) expectation.

Modifications:

- Verify onDataRead(...) is invoked atLeastOnce() instead of exactly
  once
- Assert the concatenation of all received buffers matches the sent
  payload instead of assuming a single buffer

Result:

The test no longer depends on the timing of the flow controller's DATA
frame coalescing and reliably passes regardless of whether the two
chunks are delivered as one or two DATA frames.

Co-authored-by: Norman Maurer <[email protected]>
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