Repository navigation
fix: cancel in-flight REST streaming futures on close - #1202
Conversation
kabir
left a comment
There was a problem hiding this comment.
Hi @hutiefang76 - thank you for the PR, and sorry for the delay in looking at it!
I've had a look, and think it looks good, but it needs a rebase.
Two points for the rebase:
- Preserve the native REST sseEventListener.onComplete() callbacks added by #1236. They overlap the modified streaming calls.
- Keep the documented limitation: Vert.x and Android futures still do not cancel their underlying network streams.
1b094d5 to
a78f1a6
Compare
|
Rebased onto The current affected reactor passes 798 tests with no failures, errors or skips. The 14 focused regressions pass on JVM 17 and 21, including completion preservation and real JDK connection release for both protocols. |
|
Hi @hutiefang76 Sorry, we missed this. Can you rebase again? A few observations after looking at #1355, which applies the same close pattern to the JSON-RPC transport: 1. #1355 introduced a It would be great to align this PR with that approach for consistency — otherwise the REST and JSON-RPC transports would handle close differently. 2. Exception suppression in If a handler throws during one stream's cancellation, the current loop would stop and leave remaining streams unclosed. #1355 handles this by collecting exceptions with 3. Minor: null guard parity
|
Track active REST streaming futures in both protocol implementations, remove completed futures, and cancel pending futures when closing. Cover completion, shutdown races, idempotence, and JDK socket release. This fixes a2aproject#1194
Signal normal terminal completion before cancelling HTTP streams in both REST protocol implementations. Close every stream when a terminal handler throws, and aggregate failures without self-suppression. Add regressions for cancellation errors, throwing handlers, and setup races. This fixes a2aproject#1194
a78f1a6 to
4d5a2ec
Compare
|
Rebased onto Addressed the three points in your follow-up:
The 10 added regressions fail on the rebased pre-review implementation, while its 14 existing focused tests pass. All 24 now pass on JDK 17 and 21, including real JDK HTTP connection release in both protocols. The full affected 13-module AI-assisted implementation and first-pass review: DeepSeek; coordination and native execution: OpenAI Codex. |
|
Thank you @hutiefang76 |
Description
Closing a REST transport completes and cancels every HTTP streaming request it still owns, in both the native and 0.3 compatibility clients. Normal terminal completion is signalled before cancellation, so deliberate close does not surface the JDK provider's cancellation IOException. If a terminal handler throws, the remaining streams are still closed and distinct exceptions are suppressed onto the first failure.
Rebased onto
e55888ea096e4c9068d3c3d640f2870b4856d42c. Existing native and compatibility completion callbacks, compatibility future-publication handling, HTTP configuration and redirect behavior are preserved. Streams registered while close is in progress are also completed and cancelled. Both implementations use the same non-null future contract. Borrowed HTTP clients remain caller-owned.Vert.x and Android futures still do not cancel their underlying network streams; this change does not add those provider hooks.
Related: #1194
Validation
verify: 879 tests, zero failures, errors or skips. This full run used an external source copy with only the two pre-existing MockServer tests' fixed port changed from 4001 to 59898 because 4001 was occupied locally. Those test-port changes are not in the PR. The unmodified-port full run failed at MockServer bind setup; it is not reported as passing.Contribution checklist
AI-assisted implementation and first-pass review: DeepSeek; coordination and native verification: OpenAI Codex. Test counts above come from executed Maven reports.