Preserve copy of head after taking lock on LRU list

This commit is contained in:
Jason Tedor 2015-10-08 17:46:00 -04:00
parent e0fa3297bd
commit 818d217ede
1 changed files with 2 additions and 1 deletions

View File

@ -367,9 +367,10 @@ public class Cache<K, V> {
* {@link org.elasticsearch.common.cache.RemovalNotification.RemovalReason} INVALIDATED.
*/
public void invalidateAll() {
Entry<K, V> h = head;
Entry<K, V> h;
Arrays.stream(segments).forEach(segment -> segment.segmentLock.writeLock().lock());
try (ReleasableLock ignored = lruLock.acquire()) {
h = head;
Arrays.stream(segments).forEach(segment -> segment.map = new HashMap<>());
Entry<K, V> current = head;
while (current != null) {