diff --git a/src/main/java/org/springframework/data/aerospike/cache/AerospikeCache.java b/src/main/java/org/springframework/data/aerospike/cache/AerospikeCache.java index 1ce7809be..1ae623e1f 100644 --- a/src/main/java/org/springframework/data/aerospike/cache/AerospikeCache.java +++ b/src/main/java/org/springframework/data/aerospike/cache/AerospikeCache.java @@ -197,9 +197,10 @@ public ValueWrapper putIfAbsent(Object key, Object value) { } private Key getKey(Object key) { - int userKey = key.hashCode(); - // when no arguments are given return hash code of key's class (hash code of key itself can be equal to 1) - if (key instanceof SimpleKey && key.equals(SimpleKey.EMPTY)) userKey = key.getClass().hashCode(); + int userKey = (key instanceof SimpleKey && key.equals(SimpleKey.EMPTY)) + // return hash code of key's class (hash code of key itself can be equal to 1) when no arguments are given + ? key.getClass().hashCode() + : key.hashCode(); return new Key(cacheConfiguration.getNamespace(), cacheConfiguration.getSet(), userKey); }