Repository navigation
Fix RedissonCache.retrieve(key, valueLoader) returning the internal NullValue sentinel instead of null - #7327
Merged
Conversation
…ullValue sentinel instead of null retrieve(Object, Supplier) unwraps the negative-cache sentinel on the outer lookup, but not on the inner re-check that runs after acquiring the per-key lock. Once a null value is cached for a key, every call after the first one returned the raw internal NullValue object instead of null. Applies fromStoreValue(r) to the re-checked value, matching what retrieve(Object) and get(Object, Callable) already do. Fixes redisson#7326 Signed-off-by: 심현민 <[email protected]>
mrniko
requested changes
Aug 27, 2026
| * re-check under the per-key lock reads the raw stored value without calling | ||
| * fromStoreValue(). | ||
| */ | ||
| public class RedissonCacheRetrieveNullValueTest extends RedisDockerTest { |
Member
There was a problem hiding this comment.
Add test to RedissonSpringCacheTest class
| return CompletableFuture.completedFuture(null); | ||
| }).get(); | ||
| assertNull(first, "first call should yield null"); | ||
| assertEquals(1, loaderCalls.get()); |
…eTest Address review feedback on redisson#7327: consolidate the standalone RedissonCacheRetrieveNullValueTest into the existing RedissonSpringCacheTest class instead of adding a new file, and switch assertions from JUnit to AssertJ to match the rest of the class. Signed-off-by: 심현민 <[email protected]>
Member
|
Thanks for contribution |
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.
Closes #7326
RedissonCache.retrieve(Object key, Supplier<CompletableFuture<T>> valueLoader)unwraps the negative-cache sentinel (NullValue) back tonullon the outer lookup, but not on the inner re-check that runs after acquiring the per-key lock. Once anullvalue is cached for a key, every call after the first one returns the raw internalNullValueobject instead ofnull.Changes
RedissonCache.java: applyfromStoreValue(r)to the re-checked value insideretrieve(Object, Supplier)'s lock branch, matching whatretrieve(Object)already does and what the analogous branch inget(Object, Callable)already does.RedissonCacheRetrieveNullValueTest, covering the exact reported scenario: cache anullviaretrieve(), callretrieve()again for the same key, assert the loader does not re-run and the result isnullrather than the sentinel.Testing
Ran the new test against a real Redis instance (Docker
redis:latest, via the module'sRedisDockerTestbase):Confirmed the failure was real (not a test bug) by running the test with the fix reverted first (
git stashon the one-line change, test kept in place), seeing the exact failure above, then restoring the fix and confirming it passes.