From 10a76ad5d8085a6d951a4bdfb806c713af989c12 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Tue, 2 Apr 2013 13:25:56 +0200 Subject: [PATCH] fix seen readers counter since clear can be called on percolator as well, we need to make sure we inc the counter even for non segment readers --- .../index/cache/filter/weighted/WeightedFilterCache.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/elasticsearch/index/cache/filter/weighted/WeightedFilterCache.java b/src/main/java/org/elasticsearch/index/cache/filter/weighted/WeightedFilterCache.java index fc50efa8ec0..14abf7b53de 100644 --- a/src/main/java/org/elasticsearch/index/cache/filter/weighted/WeightedFilterCache.java +++ b/src/main/java/org/elasticsearch/index/cache/filter/weighted/WeightedFilterCache.java @@ -162,9 +162,12 @@ public class WeightedFilterCache extends AbstractIndexComponent implements Filte if (cacheValue == null) { if (!cache.seenReaders.containsKey(context.reader().getCoreCacheKey())) { Boolean previous = cache.seenReaders.putIfAbsent(context.reader().getCoreCacheKey(), Boolean.TRUE); - if (previous == null && (context.reader() instanceof SegmentReader)) { - ((SegmentReader) context.reader()).addCoreClosedListener(cache); + if (previous == null) { cache.seenReadersCount.inc(); + // we add a core closed listener only, for non core IndexReaders we rely on clear being called (percolator for example) + if (context.reader() instanceof SegmentReader) { + ((SegmentReader) context.reader()).addCoreClosedListener(cache); + } } }