LUCENE-9443: UnifiedHighlighter shouldn't close reader (#1706)

A regression from 8.6.  Don't close the underlying IndexReader.
This commit is contained in:
David Smiley 2020-07-29 17:56:24 -04:00 committed by GitHub
parent 327d860a00
commit 7d5b617973
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View File

@ -196,6 +196,13 @@ Other
---------------------
(No changes)
======================= Lucene 8.6.1 =======================
Bug Fixes
---------------------
* LUCENE-9443: The UnifiedHighlighter was closing the underlying reader when there were multiple term-vector fields.
This was a regression in 8.6.0. (David Smiley, Chris Beer)
======================= Lucene 8.6.0 =======================
API Changes

View File

@ -644,7 +644,7 @@ public class UnifiedHighlighter {
batchDocIdx += fieldValsByDoc.size();
}
IOUtils.close(indexReaderWithTermVecCache);
IOUtils.close(indexReaderWithTermVecCache); // FYI won't close underlying reader
assert docIdIter.docID() == DocIdSetIterator.NO_MORE_DOCS
|| docIdIter.nextDoc() == DocIdSetIterator.NO_MORE_DOCS;
@ -1087,8 +1087,7 @@ public class UnifiedHighlighter {
.toArray(LeafReader[]::new);
return new BaseCompositeReader<IndexReader>(leafReaders) {
@Override
protected void doClose() throws IOException {
reader.close();
protected void doClose() { // don't close the underlying reader
}
@Override

View File

@ -120,6 +120,7 @@ public class TestUnifiedHighlighterTermVec extends LuceneTestCase {
assertArrayEquals(expectedSnippetsByDoc, fieldToSnippets.get(field));
}
ir.document(0); // ensure this works because the ir hasn't been closed
ir.close();
}