You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by bu...@apache.org on 2002/09/28 00:09:14 UTC

DO NOT REPLY [Bug 13102] New: - null pointer exception in termCompare

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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE : DO NOT REPLY [Bug 13102] New: - null pointer exception in termCompare

Posted by Rasik Pandey <ra...@ajlsm.com>.
It seems as it may be useful to make a fix in the termCompare methods,
atleast in our testing it hasn't caused any problems.

the new:

      if (term != null && field == term.field())

Vs.

the old:
      if (field == term.field())

Cheers,
Rasik

-----Message d'origine-----
De : bugzilla@apache.org [mailto:bugzilla@apache.org] 
Envoyé : samedi 28 septembre 2002 00:09
À : lucene-dev@jakarta.apache.org
Objet : DO NOT REPLY [Bug 13102] New: - null pointer exception in
termCompare


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:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>