Skip to content

Http2: Reserve promised stream before running the request verifier - #17495

Merged
normanmaurer merged 2 commits into
4.2from
promise_reserve
Sep 21, 2026
Merged

normanmaurer merged 2 commits into
4.2from
promise_reserve

Conversation

@normanmaurer

Copy link
Copy Markdown
Member

Motivation:

In DefaultHttp2ConnectionDecoder.onPushPromiseRead(), the promised
stream was only reserved via reservePushStream() after the
Http2PromisedRequestVerifier checks (isAuthoritative/isCacheable/
isSafe) passed. If the verifier rejected the promised request, the
method threw before the stream was ever reserved, so the connection
lost all bookkeeping of that stream ID's existence.

Modification:

  • Move the reservePushStream() call ahead of the verifier checks in
    onPushPromiseRead(), so the promised stream is reserved as soon as
    the parent stream state is validated, and any subsequent verifier
    rejection fails an already-reserved stream instead of leaving no
    record of it.
  • Add a unit test that rejects a push promise via a custom verifier
    and asserts the stream was still reserved.

Result:

The promised stream ID's existence is always tracked once a
PUSH_PROMISE is otherwise valid enough to reach verification.

Motivation:

In DefaultHttp2ConnectionDecoder.onPushPromiseRead(), the promised
stream was only reserved via reservePushStream() after the
Http2PromisedRequestVerifier checks (isAuthoritative/isCacheable/
isSafe) passed. If the verifier rejected the promised request, the
method threw before the stream was ever reserved, so the connection
lost all bookkeeping of that stream ID's existence.

Modification:

- Move the reservePushStream() call ahead of the verifier checks in
  onPushPromiseRead(), so the promised stream is reserved as soon as
  the parent stream state is validated, and any subsequent verifier
  rejection fails an already-reserved stream instead of leaving no
  record of it.
- Add a unit test that rejects a push promise via a custom verifier
  and asserts the stream was still reserved.

Result:

The promised stream ID's existence is always tracked once a
PUSH_PROMISE is otherwise valid enough to reach verification.
… a stream error

Motivation:

Bryce Anderson suggested demonstrating that, since the promised
stream is now reserved even when the request verifier rejects it, a
follow-up frame on that stream ID is cleanly attributed to that
stream (a StreamException) rather than surfacing as a broader
connection error.

Modification:

- Enhance pushPromiseReadRejectedByVerifierShouldStillReserveStream
  to send a follow-up HEADERS frame for the rejected-but-reserved
  promised stream (simulating it having since been reset and closed)
  and assert the resulting exception is a STREAM_CLOSED stream error
  scoped to that stream ID.

Result:

Test coverage now shows the practical benefit of reserving the
promised stream before validation.
@testlens-app

testlens-app Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

✅ All tests passed ✅

⚠️ TestLens detected flakiness ⚠️

Test Summary

Build PR / linux-x86_64-java25 build > Netty/Handler/Ssl/Ocsp

Test Runs Flakiness
OcspServerCertificateValidatorTest ❌ ✅ 3% 🟡

Build PR / linux-x86_64-java26 build > Netty/Handler/Ssl/Ocsp

Test Runs Flakiness
OcspServerCertificateValidatorTest ❌ ✅ 3% 🟡

🏷️ Commit: 4ae336a
▶️ Tests: 75631 executed
🟡 Checks: 31/33 completed

Test Failures

OcspServerCertificateValidatorTest (Netty/Handler/Ssl/Ocsp in Build PR / linux-x86_64-java25 build | Attempt 1/2)
java.lang.IllegalStateException: Possible memory leak detected for resource scope 'OcspServerCertificateValidatorTest'. Please use paranoid leak detection to get more information, or set -Dio.netty.util.LeakPresenceDetector.trackCreationStack=true
	at io.netty.util.LeakPresenceDetector$ResourceScope.check(LeakPresenceDetector.java:308)
	at io.netty.util.LeakPresenceDetector$ResourceScope.close(LeakPresenceDetector.java:328)
	at io.netty.util.test.LeakPresenceExtension.afterAll(LeakPresenceExtension.java:140)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
OcspServerCertificateValidatorTest (Netty/Handler/Ssl/Ocsp in Build PR / linux-x86_64-java26 build | Attempt 1/2)
java.lang.IllegalStateException: Possible memory leak detected for resource scope 'OcspServerCertificateValidatorTest'. Please use paranoid leak detection to get more information, or set -Dio.netty.util.LeakPresenceDetector.trackCreationStack=true
	at io.netty.util.LeakPresenceDetector$ResourceScope.check(LeakPresenceDetector.java:308)
	at io.netty.util.LeakPresenceDetector$ResourceScope.close(LeakPresenceDetector.java:328)
	at io.netty.util.test.LeakPresenceExtension.afterAll(LeakPresenceExtension.java:140)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1612)

Learn more about TestLens at testlens.app/docs.

@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 21, 2026
@normanmaurer
normanmaurer merged commit 8488ebd into 4.2 Sep 21, 2026
45 of 47 checks passed
@normanmaurer
normanmaurer deleted the promise_reserve branch September 21, 2026 07:26
@netty-project-bot

Copy link
Copy Markdown
Contributor

Auto-port PR for 5.0: #17562

@netty-project-bot

Copy link
Copy Markdown
Contributor

Auto-port PR for 4.1: #17563

@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 21, 2026
@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 21, 2026
normanmaurer added a commit that referenced this pull request Sep 21, 2026
…est verifier (#17562)

Auto-port of #17495 to 5.0
Cherry-picked commit: 8488ebd

---
Motivation:

In DefaultHttp2ConnectionDecoder.onPushPromiseRead(), the promised
stream was only reserved via reservePushStream() after the
Http2PromisedRequestVerifier checks (isAuthoritative/isCacheable/
isSafe) passed. If the verifier rejected the promised request, the
method threw before the stream was ever reserved, so the connection
lost all bookkeeping of that stream ID's existence.

Modification:

- Move the reservePushStream() call ahead of the verifier checks in
  onPushPromiseRead(), so the promised stream is reserved as soon as
  the parent stream state is validated, and any subsequent verifier
  rejection fails an already-reserved stream instead of leaving no
  record of it.
- Add a unit test that rejects a push promise via a custom verifier
  and asserts the stream was still reserved.

Result:

The promised stream ID's existence is always tracked once a
PUSH_PROMISE is otherwise valid enough to reach verification.

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

Auto-port of #17495 to 4.1
Cherry-picked commit: 8488ebd

---
Motivation:

In DefaultHttp2ConnectionDecoder.onPushPromiseRead(), the promised
stream was only reserved via reservePushStream() after the
Http2PromisedRequestVerifier checks (isAuthoritative/isCacheable/
isSafe) passed. If the verifier rejected the promised request, the
method threw before the stream was ever reserved, so the connection
lost all bookkeeping of that stream ID's existence.

Modification:

- Move the reservePushStream() call ahead of the verifier checks in
  onPushPromiseRead(), so the promised stream is reserved as soon as
  the parent stream state is validated, and any subsequent verifier
  rejection fails an already-reserved stream instead of leaving no
  record of it.
- Add a unit test that rejects a push promise via a custom verifier
  and asserts the stream was still reserved.

Result:

The promised stream ID's existence is always tracked once a
PUSH_PROMISE is otherwise valid enough to reach verification.

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

Auto-port of netty#17495 to 4.1
Cherry-picked commit: 8488ebd

---
Motivation:

In DefaultHttp2ConnectionDecoder.onPushPromiseRead(), the promised
stream was only reserved via reservePushStream() after the
Http2PromisedRequestVerifier checks (isAuthoritative/isCacheable/
isSafe) passed. If the verifier rejected the promised request, the
method threw before the stream was ever reserved, so the connection
lost all bookkeeping of that stream ID's existence.

Modification:

- Move the reservePushStream() call ahead of the verifier checks in
  onPushPromiseRead(), so the promised stream is reserved as soon as
  the parent stream state is validated, and any subsequent verifier
  rejection fails an already-reserved stream instead of leaving no
  record of it.
- Add a unit test that rejects a push promise via a custom verifier
  and asserts the stream was still reserved.

Result:

The promised stream ID's existence is always tracked once a
PUSH_PROMISE is otherwise valid enough to reach verification.

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.

3 participants