lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler (JIRA)" <>
Subject [jira] Updated: (LUCENE-2478) CachingWrapperFilter throws NPE when Filter.getDocIdSet() returns null
Date Wed, 26 May 2010 13:32:56 GMT


Uwe Schindler updated LUCENE-2478:

    Attachment: LUCENE-2478.patch

This fixes this bug, will commit soon.

The behaviour is now identical and null is handled equally to DocIdSet.EMPTY_DOCIDSET. DOCIDSET
is used in both cases to denote the empty set even when the filter returned null. By this
also the null value is correctly cached without additional containsKey() checks.

> CachingWrapperFilter throws NPE when Filter.getDocIdSet() returns null
> ----------------------------------------------------------------------
>                 Key: LUCENE-2478
>                 URL:
>             Project: Lucene - Java
>          Issue Type: Bug
>    Affects Versions: 2.9.1, 2.9.2, 3.0, 3.0.1
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 2.9.3, 3.0.2, 3.1, 4.0
>         Attachments: LUCENE-2478.patch
> Followup for []:
> Daniel Noll is seeing an exception like this:
> {noformat}
> java.lang.NullPointerException
>     at
>     at
>     at$LazyFilterWrapper.getDocIdSet(SourceFile:91)
>     at$ConstantScorer.<init>(
>     at$ConstantWeight.scorer(
>     at$BooleanWeight.scorer(
>     at$BooleanWeight.scorer(
>     at$2.iterator(
> {noformat}
> The class of our own is just an intermediary which delays creating the Filter object...
> {code}
> @Override
> public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
>             if (delegate == null) {
>                 delegate = factory.createFilter();
>             }
>             return delegate.getDocIdSet(reader);
> }
> {code}
> 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".

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message