From b3fd1ef5605f2f5a5fae830446c01d3a42f4142c Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Fri, 1 May 2015 09:41:46 +0000 Subject: [PATCH] remove obsolete fileLength call in IndexFileDeleter: crashes during commit no longer result in 0-length segments_N files git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1677104 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/lucene/index/IndexFileDeleter.java | 10 ---------- .../test/org/apache/lucene/index/TestIndexWriter.java | 8 +++----- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java b/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java index 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.java index 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: