lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Otis Gospodnetic (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LUCENE-689) NullPointerException thrown by equals method in SpanOrQuery
Date Fri, 20 Oct 2006 16:25:36 GMT
    [ http://issues.apache.org/jira/browse/LUCENE-689?page=comments#action_12443885 ] 
            
Otis Gospodnetic commented on LUCENE-689:
-----------------------------------------

I'd personally really want to see how come that field is null to begin with.  If possible,
could you try to debug this a bit and see what kind of SpanQueries with null fields you are
dealing with.

Even if we check for field == null and throw an exception, you won't get very far, so in the
end you'll need to figure out where this null is coming from and why.  This is not to say
that throwing an exception in case of null is not a good thing.

Thanks.


> NullPointerException thrown by equals method in SpanOrQuery
> -----------------------------------------------------------
>
>                 Key: LUCENE-689
>                 URL: http://issues.apache.org/jira/browse/LUCENE-689
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Search
>    Affects Versions: 2.1
>         Environment: Java 1.5.0_09, RHEL 3 Linux, Tomcat 5.0.28
>            Reporter: Michael Goddard
>
> Part of our code utilizes the equals method in SpanOrQuery and, in certain cases (details
to follow, if necessary), a NullPointerException gets thrown as a result of the String "field"
being null.  After applying the following patch, the problem disappeared:
> Index: src/java/org/apache/lucene/search/spans/SpanOrQuery.java
> ===================================================================
> --- src/java/org/apache/lucene/search/spans/SpanOrQuery.java    (revision 465065)
> +++ src/java/org/apache/lucene/search/spans/SpanOrQuery.java    (working copy)
> @@ -121,7 +121,8 @@
>      final SpanOrQuery that = (SpanOrQuery) o;
>      if (!clauses.equals(that.clauses)) return false;
> -    if (!field.equals(that.field)) return false;
> +    if (field != null && !field.equals(that.field)) return false;
> +    if (field == null && that.field != null) return false;
>      return getBoost() == that.getBoost();
>    }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message