Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 13257 invoked from network); 26 May 2010 06:57:02 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 26 May 2010 06:57:02 -0000 Received: (qmail 88115 invoked by uid 500); 26 May 2010 06:57:00 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 87873 invoked by uid 500); 26 May 2010 06:57:00 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 87865 invoked by uid 99); 26 May 2010 06:56:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 May 2010 06:56:59 +0000 X-ASF-Spam-Status: No, hits=0.7 required=10.0 tests=RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [74.125.83.176] (HELO mail-pv0-f176.google.com) (74.125.83.176) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 May 2010 06:56:54 +0000 Received: by pvc21 with SMTP id 21so467216pvc.35 for ; Tue, 25 May 2010 23:56:34 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.83.31 with SMTP id g31mr6282861rvb.3.1274856994091; Tue, 25 May 2010 23:56:34 -0700 (PDT) Received: by 10.140.147.18 with HTTP; Tue, 25 May 2010 23:56:33 -0700 (PDT) Date: Wed, 26 May 2010 16:56:33 +1000 Message-ID: Subject: Filter.getDocIdSet() returning null, and what this means for CachingWrapperFilter From: Daniel Noll To: Lucene Java Users Mailing List Content-Type: text/plain; charset=UTF-8 Hi all. We are seeing an exception like this: java.lang.NullPointerException at org.apache.lucene.search.CachingWrapperFilter.docIdSetToCache(CachingWrapperFilter.java:84) at org.apache.lucene.search.CachingWrapperFilter.getDocIdSet(CachingWrapperFilter.java:112) at com.nuix.storage.search.LazyConstantScoreQuery$LazyFilterWrapper.getDocIdSet(SourceFile:91) at org.apache.lucene.search.ConstantScoreQuery$ConstantScorer.(ConstantScoreQuery.java:116) at org.apache.lucene.search.ConstantScoreQuery$ConstantWeight.scorer(ConstantScoreQuery.java:81) at org.apache.lucene.search.BooleanQuery$BooleanWeight.scorer(BooleanQuery.java:297) at org.apache.lucene.search.BooleanQuery$BooleanWeight.scorer(BooleanQuery.java:297) at org.apache.lucene.search.QueryWrapperFilter$2.iterator(QueryWrapperFilter.java:75) The class of our own is just an intermediary which delays creating the Filter object... @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { if (delegate == null) { delegate = factory.createFilter(); } return delegate.getDocIdSet(reader); } Tracing through the code in CachingWrapperFilter, I can see that this NPE would occur if getDocIdSet() were to return null. The Javadoc on Filter says that null will be returned if no documents will be accepted by the filter, but it doesn't seem that Lucene itself is handling null return values correctly, so which is correct? The code or the Javadoc? Supposing that null really is OK, does this cause any problems with how CachingWrapperFilter is implementing the caching? I notice it's calling get() and then comparing against null so it wouldn't appear that it can distinguish "the entry isn't in the cache" from "the entry is in the cache but it's null". Daniel -- Daniel Noll Forensic and eDiscovery Software Senior Developer The world's most advanced Nuix email data analysis http://nuix.com/ and eDiscovery software --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org