mirror of https://github.com/apache/lucene.git
LUCENE-8200: Fix NPE in TestIndexWriter
This commit is contained in:
parent
446d38474e
commit
b7793372a9
|
@ -3100,6 +3100,7 @@ public class TestIndexWriter extends LuceneTestCase {
|
||||||
oldReader = reader;
|
oldReader = reader;
|
||||||
reader = DirectoryReader.openIfChanged(reader, writer);
|
reader = DirectoryReader.openIfChanged(reader, writer);
|
||||||
assertNotSame(reader, oldReader);
|
assertNotSame(reader, oldReader);
|
||||||
|
assertNotNull(reader);
|
||||||
oldReader.close();
|
oldReader.close();
|
||||||
searcher = new IndexSearcher(reader);
|
searcher = new IndexSearcher(reader);
|
||||||
topDocs = searcher.search(new TermQuery(new Term("id", "1")), 10);
|
topDocs = searcher.search(new TermQuery(new Term("id", "1")), 10);
|
||||||
|
@ -3202,8 +3203,12 @@ public class TestIndexWriter extends LuceneTestCase {
|
||||||
writer.forceMerge(1);
|
writer.forceMerge(1);
|
||||||
DirectoryReader oldReader = reader;
|
DirectoryReader oldReader = reader;
|
||||||
reader = DirectoryReader.openIfChanged(reader, writer);
|
reader = DirectoryReader.openIfChanged(reader, writer);
|
||||||
assertNotSame(oldReader, reader);
|
if (reader != null) {
|
||||||
oldReader.close();
|
oldReader.close();
|
||||||
|
assertNotSame(oldReader, reader);
|
||||||
|
} else {
|
||||||
|
reader = oldReader;
|
||||||
|
}
|
||||||
for (String id : ids) {
|
for (String id : ids) {
|
||||||
if (updateSeveralDocs) {
|
if (updateSeveralDocs) {
|
||||||
assertEquals(2, reader.docFreq(new Term("id", id)));
|
assertEquals(2, reader.docFreq(new Term("id", id)));
|
||||||
|
|
Loading…
Reference in New Issue