diff --git a/spring-core/src/main/java/org/springframework/util/ConcurrentLruCache.java b/spring-core/src/main/java/org/springframework/util/ConcurrentLruCache.java index acf38125ad3..f87e218af2f 100644 --- a/spring-core/src/main/java/org/springframework/util/ConcurrentLruCache.java +++ b/spring-core/src/main/java/org/springframework/util/ConcurrentLruCache.java @@ -189,13 +189,13 @@ public final class ConcurrentLruCache { public void clear() { this.evictionLock.lock(); try { - this.writeOperations.drainAll(); - Node node; - while ((node = this.evictionQueue.poll()) != null) { + for (Node node : this.cache.values()) { this.cache.remove(node.key, node); + this.evictionQueue.remove(node); markAsRemoved(node); } this.readOperations.clear(); + this.writeOperations.drainAll(); } finally { this.evictionLock.unlock();