Apache Solr open-source search software
LUCENE-6684: disable asserts on windows that false-trip due to 'pending delete' state that an NTFS file can be in
Michael McCandlessf7dc8767bb15
diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java b/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.javaindex c088700b794..7b4146c932f 100644--- a/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java+++ b/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java@@ -20,6 +20,7 @@ package org.apache.lucene.index;import org.apache.lucene.store.AlreadyClosedException;import org.apache.lucene.store.Directory;import org.apache.lucene.util.CollectionUtil;+import org.apache.lucene.util.Constants;import org.apache.lucene.util.IOUtils;import org.apache.lucene.util.InfoStream;@@ -747,8 +748,9 @@ final class IndexFileDeleter implements Closeable {} catch (IOException e) { // if delete fails// IndexWriter should only ask us to delete files it knows it wrote, so if we hit this, something is wrong!- assert e instanceof NoSuchFileException == false: "hit unexpected NoSuchFileException: file=" + fileName;- assert e instanceof FileNotFoundException == false: "hit unexpected FileNotFoundException: file=" + fileName;+ // LUCENE-6684: we suppress this assert for Windows, since a file could be in a confusing "pending delete" state:+ assert Constants.WINDOWS || e instanceof NoSuchFileException == false: "hit unexpected NoSuchFileException: file=" + fileName;+ assert Constants.WINDOWS || e instanceof FileNotFoundException == false: "hit unexpected FileNotFoundException: file=" + fileName;// Some operating systems (e.g. Windows) don't// permit a file to be deleted while it is openeddiff --git a/lucene/test-framework/src/java/org/apache/lucene/store/BaseLockFactoryTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/store/BaseLockFactoryTestCase.javaindex fc538283554..13bc0ffb3d0 100644--- a/lucene/test-framework/src/java/org/apache/lucene/store/BaseLockFactoryTestCase.java+++ b/lucene/test-framework/src/java/org/apache/lucene/store/BaseLockFactoryTestCase.java@@ -17,16 +17,6 @@ package org.apache.lucene.store;* limitations under the License.*/-import java.io.ByteArrayOutputStream;-import java.io.IOException;-import java.io.PrintStream;-import java.io.UnsupportedEncodingException;-import java.nio.file.Path;-import java.util.concurrent.CyclicBarrier;-import java.util.concurrent.atomic.AtomicBoolean;-import java.util.concurrent.atomic.AtomicInteger;-import java.util.concurrent.locks.ReentrantLock;-import org.apache.lucene.analysis.MockAnalyzer;import org.apache.lucene.document.Document;import org.apache.lucene.document.Field;@@ -39,9 +29,21 @@ import org.apache.lucene.index.Term;import org.apache.lucene.search.IndexSearcher;import org.apache.lucene.search.Query;import org.apache.lucene.search.TermQuery;+import org.apache.lucene.util.Constants;import org.apache.lucene.util.LuceneTestCase;import org.apache.lucene.util.PrintStreamInfoStream;+import java.io.ByteArrayOutputStream;+import java.io.IOException;+import java.io.PrintStream;+import java.io.UnsupportedEncodingException;+import java.nio.file.AccessDeniedException;+import java.nio.file.Path;+import java.util.concurrent.CyclicBarrier;+import java.util.concurrent.atomic.AtomicBoolean;+import java.util.concurrent.atomic.AtomicInteger;+import java.util.concurrent.locks.ReentrantLock;+/** Base class for per-LockFactory tests. */public abstract class BaseLockFactoryTestCase extends LuceneTestCase {@@ -229,10 +231,17 @@ public abstract class BaseLockFactoryTestCase extends LuceneTestCase {// IndexWriters should be "fair" (ie// FIFO).} catch (Throwable t) {- hitException = true;- System.out.println("Stress Test Index Writer: creation hit unexpected exception: " + t.toString());- t.printStackTrace(System.out);- System.out.println(toString(baos));+ if (Constants.WINDOWS && t instanceof AccessDeniedException) {+ // LUCENE-6684: suppress this: on Windows, a file in the curious "pending delete" state can+ // cause this exc on IW init, where one thread/process deleted an old+ // segments_N, but the delete hasn't finished yet because other threads/processes+ // still have it open+ } else {+ hitException = true;+ System.out.println("Stress Test Index Writer: creation hit unexpected exception: " + t.toString());+ t.printStackTrace(System.out);+ System.out.println(toString(baos));+ }break;}if (writer != null) {