fix(spring): [Cache Tracing 14] Fix cache hit detection for typed get and fix jcache docs link#5203
Draft
adinauer wants to merge 2 commits intofeat/cache-tracing-instrument-conditional-opsfrom
Conversation
The get(key, type) method incorrectly used result != null to detect cache hits, failing to distinguish a miss from a cached null value. Now uses delegate.get(key) to check the ValueWrapper first. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 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 18, 2026
Draft
Sentry Build Distribution
|
4e794ef to
4b60cec
Compare
This was referenced Mar 18, 2026
Member
Author
|
@sentry review |
Member
Author
|
cursor review |
sentry-spring-7/src/main/java/io/sentry/spring7/cache/SentryCacheWrapper.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
sentry-spring-7/src/main/java/io/sentry/spring7/cache/SentryCacheWrapper.java
Show resolved
Hide resolved
This was referenced Mar 18, 2026
Draft
Draft
Draft
8 tasks
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
Bug fix:
SentryCacheWrapper.get(Object key, Class<T> type)incorrectly usedresult != nullto determine cache hit status. Since Spring'sCache.get(key, type)returnsnullboth for cache misses and for cached null values, this caused cached nulls to be incorrectly reported as misses (cache.hit = false).The fix uses
delegate.get(key)(which returns aValueWrapper) to determine hit/miss, then callsdelegate.get(key, type)for the typed return value. Applied to all three Spring variants (spring, spring-jakarta, spring-7).Docs fix: Updated the jcache README to link to the correct docs path (
/platforms/java/integrations/jcache/).💡 Motivation and Context
Applications that legitimately cache null values would get inaccurate cache hit metrics. The
get(Object key)variant already handled this correctly viaValueWrapper— this aligns the typed overload.💚 How did you test it?
delegate.get(key)anddelegate.get(key, type)get with type creates span with cache hit true when cached value is nullget with type sets error status and throwable on exception📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
#skip-changelog