diff --git a/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java b/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java index 197ab3155f9..b118c13b0a5 100644 --- a/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java +++ b/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java @@ -313,10 +313,7 @@ final class DefaultIndexingChain extends DocConsumer { @Override public void abort() { - try { - storedFieldsConsumer.abort(); - } catch (Throwable t) { - } + storedFieldsConsumer.abort(); try { // E.g. close any open files in the term vectors writer: diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java index 7f0b97c6bab..0fc2e2476a8 100644 --- a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java +++ b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java @@ -1034,17 +1034,17 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable { /** Confirms that the incoming index sort (if any) matches the existing index sort (if any). * This is unfortunately just best effort, because it could be the old index only has unsorted flushed segments built - * before {@link Version#LUCENE_7_0_0} (flushed segments are sorted in Lucene 7.0). */ - private void validateIndexSort() { + * before {@link Version#LUCENE_6_5_0} (flushed segments are sorted in Lucene 7.0). */ + private void validateIndexSort() throws CorruptIndexException { Sort indexSort = config.getIndexSort(); if (indexSort != null) { for(SegmentCommitInfo info : segmentInfos) { Sort segmentIndexSort = info.info.getIndexSort(); if (segmentIndexSort != null && indexSort.equals(segmentIndexSort) == false) { throw new IllegalArgumentException("cannot change previous indexSort=" + segmentIndexSort + " (from segment=" + info + ") to new indexSort=" + indexSort); - } else if (segmentIndexSort == null) { - // Flushed segments are not sorted if they were built with a version prior to 7.0 - assert info.info.getVersion().onOrAfter(Version.LUCENE_7_0_0) == false; + } else if (segmentIndexSort == null && info.info.getVersion().onOrAfter(Version.LUCENE_6_5_0)) { + // Flushed segments are not sorted if they were built with a version prior to 6.5.0 + throw new CorruptIndexException("segment not sorted with indexSort=" + segmentIndexSort, info.info.toString()); } } } diff --git a/lucene/core/src/java/org/apache/lucene/index/SortingLeafReader.java b/lucene/core/src/java/org/apache/lucene/index/SortingLeafReader.java index b36b284d780..f24a4d0728e 100644 --- a/lucene/core/src/java/org/apache/lucene/index/SortingLeafReader.java +++ b/lucene/core/src/java/org/apache/lucene/index/SortingLeafReader.java @@ -42,7 +42,7 @@ import static org.apache.lucene.search.DocIdSetIterator.NO_MORE_DOCS; /** * An {@link org.apache.lucene.index.LeafReader} which supports sorting documents by a given - * {@link Sort}. This is package private and is only used by Lucene fo BWC when it needs to merge + * {@link Sort}. This is package private and is only used by Lucene for BWC when it needs to merge * an unsorted flushed segment built by an older version (newly flushed segments are sorted since version 7.0). * * @lucene.experimental diff --git a/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingLiveDocsFormat.java b/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingLiveDocsFormat.java index afc80d52642..f4abb54e803 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingLiveDocsFormat.java +++ b/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingLiveDocsFormat.java @@ -68,13 +68,8 @@ public class AssertingLiveDocsFormat extends LiveDocsFormat { @Override public void writeLiveDocs(MutableBits bits, Directory dir, SegmentCommitInfo info, int newDelCount, IOContext context) throws IOException { - MutableBits raw = bits; - /** - * bits is not necessarily an AssertingMutableBits because index sorting needs to wrap it in a sorted view. - */ - if (bits instanceof AssertingMutableBits) { - raw = (MutableBits) ((AssertingMutableBits) bits).in; - } + assert bits instanceof AssertingMutableBits; + MutableBits raw = (MutableBits) ((AssertingMutableBits)bits).in; check(raw, info.info.maxDoc(), info.getDelCount() + newDelCount); in.writeLiveDocs(raw, dir, info, newDelCount, context); }