diff --git a/server/src/main/java/org/elasticsearch/common/cache/Cache.java b/server/src/main/java/org/elasticsearch/common/cache/Cache.java index 925146610cacc..89a8362008e83 100644 --- a/server/src/main/java/org/elasticsearch/common/cache/Cache.java +++ b/server/src/main/java/org/elasticsearch/common/cache/Cache.java @@ -653,7 +653,7 @@ public void remove() { /** * Performs an action for each cache entry in the cache. While iterating over the cache entries this method is protected from mutations - * that occurs within the same cache segment by acquiring the segment's writing lock during all the iteration. As such, the specified + * that occurs within the same cache segment by acquiring the segment's read lock during all the iteration. As such, the specified * consumer should not try to modify the cache. Modifications that occur in already traveled segments won't been seen by the consumer * but modification that occur in non yet traveled segments should be. * @@ -661,7 +661,7 @@ public void remove() { */ public void forEach(BiConsumer consumer) { for (CacheSegment segment : segments) { - try (ReleasableLock ignored = segment.writeLock.acquire()) { + try (ReleasableLock ignored = segment.readLock.acquire()) { for (CompletableFuture> future : segment.map.values()) { try { if (future != null && future.isDone()) {