lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shai Erera (Commented) (JIRA)" <>
Subject [jira] [Commented] (LUCENE-3522) TermsFilter.getDocIdSet(context) NPE on missing field
Date Mon, 17 Oct 2011 12:24:10 GMT


Shai Erera commented on LUCENE-3522:

Good catch Dan!

Patch looks good, but I have some comments about the test:
# You don't close the directories at the end of it, and the test fails due that.
# I think it can be simplified to create just one Directory, with "f1:content" and request
"f2:content". I actually tried it and the test still fails (NPE reproduced without your fix).

Here is the modified, more compact, test:
  public void testMissingField() throws Exception {
    // LUCENE-3522: if requested field does not exist in the index, TermsFilter threw NPE.
    Directory dir = newDirectory();
    RandomIndexWriter writer = new RandomIndexWriter(random, dir);
    Document doc = new Document();
    doc.add(newField("f1", "content", StringField.TYPE_STORED));
    IndexReader reader = writer.getReader();
    TermsFilter tf = new TermsFilter();
    tf.addTerm(new Term("f2", "content"));
    FixedBitSet bits = (FixedBitSet) tf.getDocIdSet(reader.getTopReaderContext().leaves()[0]);
    assertTrue("Must be >= 0", bits.cardinality() >= 0);      

Would you mind changing the test case to this compact one? Or did you want to demonstrate
something else with the two readers?
> TermsFilter.getDocIdSet(context) NPE on missing field
> -----------------------------------------------------
>                 Key: LUCENE-3522
>                 URL:
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: modules/other
>    Affects Versions: 4.0
>            Reporter: Dan Climan
>            Assignee: Michael McCandless
>            Priority: Minor
>         Attachments: LUCENE-3522.patch
> If the context does not contain the field for a term when calling TermsFilter.getDocIdSet(AtomicReaderContext
context) then a NullPointerException is thrown due to not checking for null Terms before getting

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


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

View raw message