lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 13102] New: - null pointer exception in termCompare
Date Fri, 27 Sep 2002 22:09:14 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13102>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13102

null pointer exception in termCompare

           Summary: null pointer exception in termCompare
           Product: Lucene
           Version: 1.2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Search
        AssignedTo: lucene-dev@jakarta.apache.org
        ReportedBy: sberents@hotmail.com


WildcardTermEnum or FuzzyTermQueryEnum both call setEnum in their constructors. 
Inside the superclass, FilteredTermEnum, I find:
    protected void setEnum(TermEnum actualEnum) throws IOException {
        this.actualEnum = actualEnum;
        // Find the first term that matches
        Term term = actualEnum.term();
        if (termCompare(term))
            currentTerm = term;
        else next();
    }

Because setEnum is actually called with parameter reader.terms(<some term>), 
the expression 'actualEnum.term()' could return null. None of the termCompare 
methods check for a null parameter, and they will throw a null pointer 
exception in that case. I ran into the situation that a wildcard or fuzzy 
search in the nonexistent field 'm' would correctly return 0 results, but the 
same search in the non-existent field 'x' would throw a null pointer exception 
in the correctsponding termCompare method.
The following temporary fix in abstract class FilteredTermEnum solved the 
problem:
    protected void setEnum(TermEnum actualEnum) throws IOException {
        this.actualEnum = actualEnum;
        // Find the first term that matches
        Term term = actualEnum.term();
        if(term == null) return;      // temporary fix -sjb
        if (termCompare(term))
            currentTerm = term;
        else next();
    }

--
To unsubscribe, e-mail:   <mailto:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>


Mime
View raw message