Repository navigation
Conversation
Release SDK streams on completion, error, and cancellation. Run blocking stream creation, iteration, and cancellation cleanup on boundedElastic while recording cancellation immediately. Close responses arriving after cancellation without further reads and report late cleanup failures through Reactor's dropped-error hook. Add regression tests for resource cleanup, blocked reads, cancellation races, and combined stream and cleanup failures. Fixes spring-projects#7245 Signed-off-by: Beni Kim <sejoung@gmail.com>
sejoung
force-pushed
the
fix/google-genai-stream-cleanup
branch
from
October 29, 2026 08:11
abe88b0 to
90d0a3b
Compare
Fixes spring-projects#7245 Signed-off-by: Beni Kim <sejoung@gmail.com>
sejoung
force-pushed
the
fix/google-genai-stream-cleanup
branch
from
November 27, 2026 05:48
c76b873 to
fe36855
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7245
GoogleGenAiChatModelconsumes the SDK'sResponseStreamthroughFlux.fromIterable()without registering resource cleanup.As a result, the adapter does not explicitly close the SDK response on completion, error, or cancellation.
This PR connects SDK resource cleanup to the Reactor subscription lifecycle.
It also addresses cancellation cases identified while testing the initial cleanup change.
Changes
boundedElastic().boundedElastic()so the cancelling thread does not wait for SDK cleanup.Regression tests
Tests use controlled in-memory responses while exercising the actual Google SDK SSE parsing.
Coverage includes:
boundedElastic(), including demand from another thread.Validation
Limitations
This change does not introduce direct transport-level request cancellation.
An SDK network read may remain blocked until data arrives, a timeout occurs, or the transport otherwise unblocks it.
Cancellation is recorded immediately, and the cancelling thread no longer waits for SDK cleanup.
The tests do not verify cancellation against the actual Gemini service or its HTTP/2 behavior.