fix: suppress CancellationException in JDK HTTP client SSE streaming#951
fix: suppress CancellationException in JDK HTTP client SSE streaming#951ehsavoie wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request modifies JdkA2AHttpClient to prevent CancellationException from being propagated to the error consumer during asynchronous SSE stream processing. It updates the error handling logic in both the subscriber's onError method and the future's completion handler to filter out CancellationException. Additionally, it removes redundant subscription cancellation calls and adds comprehensive unit tests to verify this behavior. There are no review comments, so no further feedback is provided.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Filter out CancellationException in both the reactive subscriber's onError and the CompletableFuture error handler to prevent spurious error propagation when the HTTP client is closed during an active SSE stream. Also fix a race between onError and onComplete by using compareAndSet in onComplete, and remove redundant subscription.cancel() calls. This fixes a2aproject#946 Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
db53b2b to
9803e94
Compare
…endpoints Streaming endpoints in MultiVersionJSONRPCRoutes and MultiVersionRestRoutes were using runInRequestContext() which destroys the CDI context immediately, before the async agent thread can access @RequestScoped beans. Switch to runInRequestContextDeferred() which defers destruction until the SSE response completes. Also refactors MultiVersionRestRoutes to deduplicate dispatch methods by adding a boolean streaming parameter and a runInContext() helper. Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces several improvements and bug fixes across different modules. In the HTTP client, it prevents CancellationException from being propagated to the error consumer during asynchronous SSE operations and ensures thread-safe state transitions in onComplete. Corresponding unit tests have been added to verify this behavior. In the multi-version JSON-RPC and REST routing components, the request context handling has been updated to support deferred CDI context destruction for streaming endpoints. Finally, the multi-instance replication test was updated to use a more robust condition for verifying subscription establishment. No review comments were provided, and I have no additional feedback to offer.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Filter out CancellationException in both the reactive subscriber's onError and the CompletableFuture error handler to prevent spurious error propagation when the HTTP client is closed during an active SSE stream. Also fix a race between onError and onComplete by using compareAndSet in onComplete, and remove redundant subscription.cancel() calls.
This fixes #946 🦕