diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/caching/Cache.java b/src/main/java/ca/recrown/islandsurvivalcraft/caching/Cache.java index deb85ec..9dbc073 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/caching/Cache.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/caching/Cache.java @@ -31,11 +31,11 @@ public class Cache { if (data.size() > maxSize) { int occ = 0; do { + Key potentialKey = occurrenceOrder.poll(); + CacheValue potential = data.get(potentialKey); + potential.occurrence--; cleaningLock.lock(); try { - Key potentialKey = occurrenceOrder.poll(); - CacheValue potential = data.get(potentialKey); - potential.occurrence--; occ = potential.occurrence; if (occ < 1) { data.remove(potentialKey);