From 86d5a69cabf841d7057d60dd7a72fd60454d48de Mon Sep 17 00:00:00 2001 From: Mouamle Date: Fri, 13 Dec 2019 14:48:32 +0300 Subject: [PATCH] probable null pointer exception eliminated. --- .../java/com/github/hussainderry/cache/ConcurrentCache.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; } /**