LUCENE-7592: if segments file is truncated, throw CorruptIndexException

This commit is contained in:
Mike McCandless 2016-12-14 18:00:51 -05:00
parent 6525bb56f0
commit e4f31fab2f
2 changed files with 10 additions and 1 deletions

View File

@ -138,6 +138,10 @@ Improvements
necessarily refer to that field (AKA requireFieldMatch==false). Disabled by default.
See UH get/setFieldMatcher. (Jim Ferenczi via David Smiley)
* LUCENE-7592: If the segments file is truncated, we now throw
CorruptIndexException instead of the more confusing EOFException
(Mike Drob via Mike McCandless)
Optimizations
* LUCENE-7568: Optimize merging when index sorting is used but the

View File

@ -17,6 +17,7 @@
package org.apache.lucene.index;
import java.io.EOFException;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
@ -277,7 +278,11 @@ public final class SegmentInfos implements Cloneable, Iterable<SegmentCommitInfo
long generation = generationFromSegmentsFileName(segmentFileName);
//System.out.println(Thread.currentThread() + ": SegmentInfos.readCommit " + segmentFileName);
try (ChecksumIndexInput input = directory.openChecksumInput(segmentFileName, IOContext.READ)) {
return readCommit(directory, input, generation);
try {
return readCommit(directory, input, generation);
} catch (EOFException e) {
throw new CorruptIndexException("Unexpected end of file while reading index.", input, e);
}
}
}