You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2016/07/11 09:33:29 UTC

lucene-solr:master: Remove IW.slowFileExists, since it's only called from "used to be helpful but now useless" asserts:

Repository: lucene-solr
Updated Branches:
  refs/heads/master 42e1caf2b -> 044aabfb3


Remove IW.slowFileExists, since it's only called from "used to be helpful but now useless" asserts:

  - Directory.copyFrom now throws an exception if the test already exists

  - Directory.sync now throws an exception if a file name didn't already exist


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/044aabfb
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/044aabfb
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/044aabfb

Branch: refs/heads/master
Commit: 044aabfb30b3da02378c33392a86adc7942921a8
Parents: 42e1caf
Author: Mike McCandless <mi...@apache.org>
Authored: Mon Jul 11 05:32:56 2016 -0400
Committer: Mike McCandless <mi...@apache.org>
Committed: Mon Jul 11 05:32:56 2016 -0400

----------------------------------------------------------------------
 .../org/apache/lucene/index/IndexWriter.java     | 19 -------------------
 1 file changed, 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/044aabfb/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
----------------------------------------------------------------------
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 91b67e8..0fb23d9 100644
--- a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
@@ -17,9 +17,7 @@
 package org.apache.lucene.index;
 
 import java.io.Closeable;
-import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.nio.file.NoSuchFileException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -2885,9 +2883,6 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
       // Copy the segment's files
       for (String file: info.files()) {
         final String newFileName = newInfo.namedForThisSegment(file);
-
-        assert !slowFileExists(directory, newFileName): "file \"" + newFileName + "\" already exists; newInfo.files=" + newInfo.files();
-
         directory.copyFrom(info.info.dir, file, newFileName, context);
         copiedFiles.add(newFileName);
       }
@@ -4542,7 +4537,6 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
     
     Collection<String> files = toSync.files(false);
     for(final String fileName: files) {
-      assert slowFileExists(directory, fileName): "file " + fileName + " does not exist; files=" + Arrays.toString(directory.listAll());
       // If this trips it means we are missing a call to
       // .checkpoint somewhere, because by the time we
       // are called, deleter should know about every
@@ -4999,19 +4993,6 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
     void process(IndexWriter writer, boolean triggerMerge, boolean clearBuffers) throws IOException;
   }
 
-  /** Used only by asserts: returns true if the file exists
-   *  (can be opened), false if it cannot be opened, and
-   *  (unlike Java's File.exists) throws IOException if
-   *  there's some unexpected error. */
-  static boolean slowFileExists(Directory dir, String fileName) throws IOException {
-    try {
-      dir.openInput(fileName, IOContext.DEFAULT).close();
-      return true;
-    } catch (NoSuchFileException | FileNotFoundException e) {
-      return false;
-    }
-  }
-
   /** Anything that will add N docs to the index should reserve first to
    *  make sure it's allowed.  This will throw {@code
    *  IllegalArgumentException} if it's not allowed. */