LUCENE-9501: Fix invariant violation in IndexSortSortedNumericDocValuesRangeQuery. (#1833)

Previously the DocIdSetIterator returned an old value for docID advance
returned NO_MORE_DOCS. This violates the DocIdSetIterator contract and made it
possiblefor the iterator's advance method to be called even after it was
already exhausted.
This commit is contained in:
Julie Tibshirani 2020-09-10 12:02:18 -07:00 committed by GitHub
parent 0250978869
commit 37e4dbef6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View File

@ -239,6 +239,9 @@ Bug Fixes
already exists instead of opening an IndexInput on the file which might throw a AccessDeniedException already exists instead of opening an IndexInput on the file which might throw a AccessDeniedException
in some Directory implementations. (Simon Willnauer) in some Directory implementations. (Simon Willnauer)
* LUCENE-9501: Fix a bug in IndexSortSortedNumericDocValuesRangeQuery where it could violate the
DocIdSetIterator contract. (Julie Tibshirani)
Documentation Documentation
--------------------- ---------------------

View File

@ -287,10 +287,10 @@ public class IndexSortSortedNumericDocValuesRangeQuery extends Query {
int result = delegate.advance(target); int result = delegate.advance(target);
if (result < lastDoc) { if (result < lastDoc) {
docID = result; docID = result;
return docID;
} else { } else {
return NO_MORE_DOCS; docID = NO_MORE_DOCS;
} }
return docID;
} }
@Override @Override

View File

@ -65,7 +65,7 @@ public class TestIndexSortSortedNumericDocValuesRangeQuery extends LuceneTestCas
iw.deleteDocuments(LongPoint.newRangeQuery("idx", 0L, 10L)); iw.deleteDocuments(LongPoint.newRangeQuery("idx", 0L, 10L));
} }
final IndexReader reader = iw.getReader(); final IndexReader reader = iw.getReader();
final IndexSearcher searcher = newSearcher(reader, false); final IndexSearcher searcher = newSearcher(reader);
iw.close(); iw.close();
for (int i = 0; i < 100; ++i) { for (int i = 0; i < 100; ++i) {