diff --git a/src/main/java/com/github/hussainderry/cache/ConcurrentCache.java b/src/main/java/com/github/hussainderry/cache/ConcurrentCache.java index 1ecc0c2..e0612fb 100755 --- a/src/main/java/com/github/hussainderry/cache/ConcurrentCache.java +++ b/src/main/java/com/github/hussainderry/cache/ConcurrentCache.java @@ -62,7 +62,8 @@ public void put(K key, V value){ * @return The old value corresponding to the provided key * */ public V putIfAbsent(K key, V value){ - return mMap.putIfAbsent(key, new Holder<>(value)).getValue(); + Holder vHolder = mMap.putIfAbsent(key, new Holder<>(value)); + return vHolder != null ? vHolder.getValue() : null; } /**