Apache Lucene open-source search software
remove obsolete fileLength call in IndexFileDeleter: crashes during commit no longer result in 0-length segments_N files
Michael McCandlessb3fd1ef5605f
diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java b/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.javaindex 3688ac1beb2..2500c03cd3c 100644--- a/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java+++ b/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java@@ -143,8 +143,6 @@ final class IndexFileDeleter implements Closeable {// First pass: walk the files and initialize our ref// counts:- long currentGen = segmentInfos.getGeneration();-CommitPoint currentCommitPoint = null;String[] files = directory.listAll();@@ -179,14 +177,6 @@ final class IndexFileDeleter implements Closeable {if (infoStream.isEnabled("IFD")) {infoStream.message("IFD", "init: hit FileNotFoundException when loading commit \"" + fileName + "\"; skipping this commit point");}- } catch (IOException e) {- if (SegmentInfos.generationFromSegmentsFileName(fileName) <= currentGen && directory.fileLength(fileName) > 0) {- throw e;- } else {- // Most likely we are opening an index that- // has an aborted "future" commit, so suppress- // exc in this case- }}if (sis != null) {final CommitPoint commitPoint = new CommitPoint(commitsToDelete, directory, sis);diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.javaindex ba8c88465fa..a66541fe7d3 100644--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java@@ -73,7 +73,6 @@ import org.apache.lucene.store.RAMDirectory;import org.apache.lucene.store.SimpleFSLockFactory;import org.apache.lucene.util.Bits;import org.apache.lucene.util.BytesRef;-import org.apache.lucene.util.Constants;import org.apache.lucene.util.IOUtils;import org.apache.lucene.util.InfoStream;import org.apache.lucene.util.LuceneTestCase;@@ -2321,7 +2320,9 @@ public class TestIndexWriter extends LuceneTestCase {BaseDirectoryWrapper dir = newDirectory();// Create a corrupt first commit:- dir.createOutput("segments_0", IOContext.DEFAULT).close();+ dir.createOutput(IndexFileNames.fileNameFromGeneration(IndexFileNames.PENDING_SEGMENTS,+ "",+ 0), IOContext.DEFAULT).close();IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));int mode = i/2;@@ -2343,9 +2344,6 @@ public class TestIndexWriter extends LuceneTestCase {} else {new IndexWriter(dir, iwc).rollback();}- if (mode != 0) {- fail("expected exception");- }} catch (IOException ioe) {// OpenMode.APPEND should throw an exception since no// index exists: