Skip to content

Fix HTTP/1 active-request metric lifecycle when connection closes before request body completes - #6336

Open
tsegismont wants to merge 1 commit into
eclipse-vertx:masterfrom
tsegismont:issue/6328
Open

Fix HTTP/1 active-request metric lifecycle when connection closes before request body completes#6336
tsegismont wants to merge 1 commit into
eclipse-vertx:masterfrom
tsegismont:issue/6328

Conversation

@tsegismont

@tsegismont tsegismont commented Aug 28, 2026

Copy link
Copy Markdown
Member

When the server sends an early response before the request body is fully received and the client then closes the connection, responseEnd() is already called by reportResponseComplete() at response-write time. The additional requestReset() call in handleClosed() violates the SPI contract of exactly one terminal call per request.

Fix handleClosed() by delegating to requestInProgress.handleException() behind a requestInProgress.response != null guard, which skips pipelined requests where handleBegin() was never called (avoiding a null metric NPE) and relies on the existing !response.ended() check to prevent a double terminal call.

Apply the same response != null guard to handleException() to prevent the equivalent NPE under IO errors.

Add two regression tests using Vert.x NetClient: one verifying that responseEnd is the terminal call when an early 401 is sent and the client closes before delivering the body; one verifying that requestReset is the terminal call when the client closes before the body with no response sent.

Assisted-by: Anthropic Claude (claude-sonnet-4-6)

Comment thread vertx-core/src/test/java/io/vertx/tests/metrics/Http1xMetricsTest.java Outdated
…ore request body completes

When the server sends an early response before the request body is fully received and the client then closes the connection, responseEnd() is already called by reportResponseComplete() at response-write time. The additional requestReset() call in handleClosed() violates the SPI contract of exactly one terminal call per request.

Fix handleClosed() by delegating to requestInProgress.handleException() behind a requestInProgress.response != null guard, which skips pipelined requests where handleBegin() was never called (avoiding a null metric NPE) and relies on the existing !response.ended() check to prevent a double terminal call.

Apply the same response != null guard to handleException() to prevent the equivalent NPE under IO errors.

Add two regression tests using Vert.x NetClient: one verifying that responseEnd is the terminal call when an early 401 is sent and the client closes before delivering the body; one verifying that requestReset is the terminal call when the client closes before the body with no response sent.

Assisted-by: Anthropic Claude (claude-sonnet-4-6)
Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
@tsegismont tsegismont changed the title Correct HTTP/1 active-request metric lifecycle for early responses Fix HTTP/1 active-request metric lifecycle when connection closes before request body completes Aug 28, 2026
@tsegismont
tsegismont requested a review from vietj August 28, 2026 15:49
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