feat(spring7): [Cache Tracing 8] Add retrieve() overrides for reactive/async cache support#5184
Draft
adinauer wants to merge 1 commit intofeat/cache-tracing-all-samplesfrom
Draft
feat(spring7): [Cache Tracing 8] Add retrieve() overrides for reactive/async cache support#5184adinauer wants to merge 1 commit intofeat/cache-tracing-all-samplesfrom
adinauer wants to merge 1 commit intofeat/cache-tracing-all-samplesfrom
Conversation
Adds support for Spring 6.1+ async cache operations (CompletableFuture and Mono/Flux). Without these overrides, @Cacheable on reactive return types crashes with UnsupportedOperationException. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. This PR will not appear in the changelog. 🤖 This preview updates automatically when you update the PR. |
This was referenced Mar 10, 2026
Contributor
|
This was referenced Mar 10, 2026
Member
Author
|
cursor review |
Member
Author
|
@sentry review |
Sentry Build Distribution
|
Contributor
Performance metrics 🚀
|
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.
PR Stack (Cache Tracing)
📜 Description
Adds
retrieve(Object key)andretrieve(Object key, Supplier<CompletableFuture<T>>)overrides toSentryCacheWrapper.Spring 6.1+ added these two methods to the
Cacheinterface for non-blocking cache operations. Spring'sCacheInterceptorcalls them when@Cacheableis placed on methods returningCompletableFuture<T>orMono<T>. Without these overrides, the defaultCache.retrieve()throwsUnsupportedOperationException, meaning any app using reactive@Cacheablewith cache tracing enabled would crash.Key design decisions:
CompletableFuture.whenComplete()retrieve(key)handles three result states:nullreturn (immediate miss), CF resolving tonull(late miss), CF resolving to value (hit)retrieve(key, valueLoader)uses the sameAtomicBooleanloader-tracking pattern asget(key, Callable)for cache hit detection💡 Motivation and Context
This is a functional bug fix. The
SentryCacheWrapperimplementsCachebut didn't override theretrieve()default methods, which throwUnsupportedOperationException. When cache tracing is enabled and the wrapper intercepts the cache, reactive@Cacheablemethods crash instead of working.💚 How did you test it?
SentryCacheWrapperTestcovering:retrievevariants📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
Port
retrieve()overrides tosentry-spring-jakartawhen cache classes are ported there.#skip-changelog