From 2357f0c10693d0e91b9de345ae2765ac653e5065 Mon Sep 17 00:00:00 2001 From: Otis Gospodnetic Date: Tue, 16 Sep 2003 12:52:10 +0000 Subject: [PATCH] - Fixed bug 20290 http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20290 - Added @version. git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150033 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/lucene/search/QueryFilter.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/lucene/search/QueryFilter.java b/src/java/org/apache/lucene/search/QueryFilter.java index dc3b466c6c0..07950179047 100644 --- a/src/java/org/apache/lucene/search/QueryFilter.java +++ b/src/java/org/apache/lucene/search/QueryFilter.java @@ -68,10 +68,12 @@ import org.apache.lucene.index.IndexReader; * QueryFilter that matches, e.g., only documents modified within the last * week. The QueryFilter and RangeQuery would only need to be reconstructed * once per day. + * + * @version $Id$ */ public class QueryFilter extends Filter { private Query query; - private transient WeakHashMap cache = new WeakHashMap(); + private transient WeakHashMap cache = null; /** Constructs a filter which only matches documents matching * query. @@ -82,6 +84,10 @@ public class QueryFilter extends Filter { public BitSet bits(IndexReader reader) throws IOException { + if (cache == null) { + cache = new WeakHashMap(); + } + synchronized (cache) { // check cache BitSet cached = (BitSet) cache.get(reader); if (cached != null) { @@ -97,7 +103,6 @@ public class QueryFilter extends Filter { } }); - synchronized (cache) { // update cache cache.put(reader, bits); }