mirror of https://github.com/apache/lucene.git
LUCENE-9133 Fix for potential NPE in TermFilteredPresearcher#buildQuery
This commit is contained in:
parent
ac866a67de
commit
84f6507452
|
@ -154,6 +154,8 @@ Bug Fixes
|
|||
* LUCENE-8908: Return default value from objectVal when doc doesn't match the query in QueryValueSource
|
||||
(Bill Bell, hossman, Munendra S N, Michele Palmia)
|
||||
|
||||
* LUCENE-9133: Fix for potential NPE in TermFilteredPresearcher for empty fields (Marvin Justice via Mike Drob)
|
||||
|
||||
Other
|
||||
---------------------
|
||||
|
||||
|
|
|
@ -105,7 +105,12 @@ public class TermFilteredPresearcher extends Presearcher {
|
|||
DocumentQueryBuilder queryBuilder = getQueryBuilder();
|
||||
for (FieldInfo field : reader.getFieldInfos()) {
|
||||
|
||||
TokenStream ts = new TermsEnumTokenStream(reader.terms(field.name).iterator());
|
||||
Terms terms = reader.terms(field.name);
|
||||
if (terms == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TokenStream ts = new TermsEnumTokenStream(terms.iterator());
|
||||
for (CustomQueryHandler handler : queryHandlers) {
|
||||
ts = handler.wrapTermStream(field.name, ts);
|
||||
}
|
||||
|
|
|
@ -131,6 +131,7 @@ public class TestTermPresearcher extends PresearcherTestBase {
|
|||
|
||||
MemoryIndex mindex = new MemoryIndex();
|
||||
mindex.addField("f", "this is a test document", WHITESPACE);
|
||||
mindex.addField("g", "#######", ANALYZER); // analyzes away to empty field
|
||||
LeafReader docsReader = (LeafReader) mindex.createSearcher().getIndexReader();
|
||||
|
||||
QueryIndex.QueryTermFilter termFilter = new QueryIndex.QueryTermFilter(reader);
|
||||
|
@ -149,4 +150,5 @@ public class TestTermPresearcher extends PresearcherTestBase {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue