Skip to content

Commit 082e0c8

Browse files
committed
readLock
1 parent 58b7bd9 commit 082e0c8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • server/src/main/java/org/elasticsearch/common/cache

server/src/main/java/org/elasticsearch/common/cache/Cache.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,15 +653,15 @@ public void remove() {
653653

654654
/**
655655
* Performs an action for each cache entry in the cache. While iterating over the cache entries this method is protected from mutations
656-
* that occurs within the same cache segment by acquiring the segment's writing lock during all the iteration. As such, the specified
656+
* that occurs within the same cache segment by acquiring the segment's read lock during all the iteration. As such, the specified
657657
* consumer should not try to modify the cache. Modifications that occur in already traveled segments won't been seen by the consumer
658658
* but modification that occur in non yet traveled segments should be.
659659
*
660660
* @param consumer the {@link Consumer}
661661
*/
662662
public void forEach(BiConsumer<K, V> consumer) {
663663
for (CacheSegment<K, V> segment : segments) {
664-
try (ReleasableLock ignored = segment.writeLock.acquire()) {
664+
try (ReleasableLock ignored = segment.readLock.acquire()) {
665665
for (CompletableFuture<Entry<K, V>> future : segment.map.values()) {
666666
try {
667667
if (future != null && future.isDone()) {

0 commit comments

Comments
 (0)