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:36:56 UTC
lucene-solr:branch_6x: Remove IW.slowFileExists,
since it's only called from "used to be helpful but now useless"
asserts:
Repository: lucene-solr
Updated Branches:
refs/heads/branch_6x 9d8cc80a7 -> 15526e776
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/15526e77
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/15526e77
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/15526e77
Branch: refs/heads/branch_6x
Commit: 15526e776ad0c0000f9c1d483f1c59fefe46ec16
Parents: 9d8cc80
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:33:47 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/15526e77/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 fd25536..6a8e1ed 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);
}
@@ -4567,7 +4562,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
@@ -5024,19 +5018,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. */