diff --git a/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java b/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java index 2bc956d1f9c..d0789dca5e3 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java @@ -1229,14 +1229,7 @@ public class TestAddIndexes extends LuceneTestCase { Directory src = newDirectory(), dest = newDirectory(); RandomIndexWriter w = new RandomIndexWriter(random(), src); w.addDocument(new Document()); - IndexReader allDeletedReader = new FilterAtomicReader(w.getReader().leaves().get(0).reader()) { - @Override - public Bits getLiveDocs() { - return new Bits.MatchNoBits(in.maxDoc()); - } - @Override public boolean hasDeletions() { return true; } - @Override public int numDocs() { return 0; } - }; + IndexReader allDeletedReader = new AllDeletedFilterReader(w.getReader().leaves().get(0).reader()); w.close(); w = new RandomIndexWriter(random(), dest); diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/AllDeletedFilterReader.java b/lucene/test-framework/src/java/org/apache/lucene/index/AllDeletedFilterReader.java index 6667607ac5b..d20583f9c6a 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/index/AllDeletedFilterReader.java +++ b/lucene/test-framework/src/java/org/apache/lucene/index/AllDeletedFilterReader.java @@ -28,6 +28,7 @@ public class AllDeletedFilterReader extends FilterAtomicReader { public AllDeletedFilterReader(AtomicReader in) { super(in); liveDocs = new Bits.MatchNoBits(in.maxDoc()); + assert maxDoc() == 0 || hasDeletions(); } @Override