Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

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

Mike McCandless044aabfb30b3
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 91b67e8d73c..0fb23d96b36 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. */