diff --git a/src/java/org/apache/lucene/index/MultiSegmentReader.java b/src/java/org/apache/lucene/index/MultiSegmentReader.java index 92febb03ef5..a95791082eb 100644 --- a/src/java/org/apache/lucene/index/MultiSegmentReader.java +++ b/src/java/org/apache/lucene/index/MultiSegmentReader.java @@ -106,6 +106,10 @@ class MultiSegmentReader extends DirectoryIndexReader implements Cloneable { try { SegmentReader newReader; if (newReaders[i] == null || infos.info(i).getUseCompoundFile() != newReaders[i].getSegmentInfo().getUseCompoundFile()) { + + // We should never see a totally new segment during cloning + assert !doClone; + // this is a new reader; in case we hit an exception we can close it safely newReader = SegmentReader.get(readOnly, infos.info(i)); } else { diff --git a/src/java/org/apache/lucene/index/SegmentReader.java b/src/java/org/apache/lucene/index/SegmentReader.java index d37db837126..552b9a2bb40 100644 --- a/src/java/org/apache/lucene/index/SegmentReader.java +++ b/src/java/org/apache/lucene/index/SegmentReader.java @@ -671,6 +671,10 @@ class SegmentReader extends DirectoryIndexReader { return this; } + // When cloning, the incoming SegmentInfos should not + // have any changes in it: + assert !doClone || (normsUpToDate && deletionsUpToDate); + // clone reader SegmentReader clone; try {