diff --git a/redisson/src/main/java/org/redisson/cache/AbstractCacheMap.java b/redisson/src/main/java/org/redisson/cache/AbstractCacheMap.java index 8a653d058..c241f53e4 100644 --- a/redisson/src/main/java/org/redisson/cache/AbstractCacheMap.java +++ b/redisson/src/main/java/org/redisson/cache/AbstractCacheMap.java @@ -542,14 +542,15 @@ public abstract class AbstractCacheMap implements Cache { @Override public V computeIfAbsent(K key, Function mappingFunction) { - AtomicReference result = new AtomicReference<>(); - map.computeIfAbsent(key, k -> { + CachedValue v = map.computeIfAbsent(key, k -> { V value = mappingFunction.apply(k); - result.set(value); CachedValue entry = create(key, value, timeToLiveInMillis, maxIdleInMillis); return entry; }); - return result.get(); + if (v != null) { + return v.getValue(); + } + return null; } }