forked from spring-projects/spring-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid duplicate upstream subscription during reactive cache put
This commit fixes an issue where a Cacheable method which returns a Flux (or multi-value publisher) will be invoked once, but the returned publisher is actually subscribed twice. By using the Reactor `tap` operator, we ensure that we can emit values downstream AND accumulate emitted values into the List with a single subscription. The SignalListener additionally handles scenarios involving cancel, for instance in case of a `take(1)` in the chain. In that case values emitted up until that point will have been stored into the List buffer, so we can still put it in the cache. In case of error, no caching occurs and the internal buffer is cleared. This implementation also protects against competing onComplete/onError signals and cancel signals. Closes spring-projectsgh-32370
- Loading branch information
1 parent
a0ae849
commit 988f363
Showing
2 changed files
with
42 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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