WW-5355 Prevent AtomicInteger being initialised to zero

This commit is contained in:
Kusal Kithul-Godage
2023-10-15 13:49:24 +11:00
parent 74d2fdcc6c
commit 5011a79777
2 changed files with 4 additions and 4 deletions
@@ -30,10 +30,10 @@ import java.util.concurrent.atomic.AtomicInteger;
public class OgnlDefaultCache<Key, Value> implements OgnlCache<Key, Value> {
private final ConcurrentHashMap<Key, Value> ognlCache;
private final AtomicInteger cacheEvictionLimit = new AtomicInteger();
private final AtomicInteger cacheEvictionLimit;
public OgnlDefaultCache(int evictionLimit, int initialCapacity, float loadFactor) {
cacheEvictionLimit.set(evictionLimit);
cacheEvictionLimit = new AtomicInteger(evictionLimit);
ognlCache = new ConcurrentHashMap<>(initialCapacity, loadFactor);
}
@@ -36,10 +36,10 @@ import java.util.concurrent.atomic.AtomicInteger;
public class OgnlLRUCache<Key, Value> implements OgnlCache<Key, Value> {
private final Map<Key, Value> ognlLRUCache;
private final AtomicInteger cacheEvictionLimit = new AtomicInteger();
private final AtomicInteger cacheEvictionLimit;
public OgnlLRUCache(int evictionLimit, int initialCapacity, float loadFactor) {
cacheEvictionLimit.set(evictionLimit);
cacheEvictionLimit = new AtomicInteger(evictionLimit);
// Access-order mode selected (order mode true in LinkedHashMap constructor).
ognlLRUCache = Collections.synchronizedMap (new LinkedHashMap<Key, Value>(initialCapacity, loadFactor, true) {
@Override