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/02/03 10:23:15 UTC

[2/5] lucene-solr git commit: migrate current patch from svn

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/core/src/test/org/apache/lucene/store/TestSimpleFSLockFactory.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/store/TestSimpleFSLockFactory.java b/lucene/core/src/test/org/apache/lucene/store/TestSimpleFSLockFactory.java
index f05297e..793c005 100644
--- a/lucene/core/src/test/org/apache/lucene/store/TestSimpleFSLockFactory.java
+++ b/lucene/core/src/test/org/apache/lucene/store/TestSimpleFSLockFactory.java
@@ -19,8 +19,10 @@ package org.apache.lucene.store;
 
 import java.io.IOException;
 import java.nio.file.Path;
+import java.util.Collections;
 
 import org.apache.lucene.util.IOUtils;
+import org.apache.lucene.util.TestUtil;
 
 /** Simple tests for SimpleFSLockFactory */
 public class TestSimpleFSLockFactory extends BaseLockFactoryTestCase {
@@ -34,11 +36,12 @@ public class TestSimpleFSLockFactory extends BaseLockFactoryTestCase {
   public void testDeleteLockFile() throws IOException {
     Directory dir = getDirectory(createTempDir());
     try {
+      assumeFalse("test directly deletes lock files", TestUtil.hasVirusChecker(dir));
       Lock lock = dir.obtainLock("test.lock");
       lock.ensureValid();
     
       try {
-        dir.deleteFile("test.lock");
+        dir.deleteFiles(Collections.singleton("test.lock"));
       } catch (Exception e) {
         // we can't delete a file for some reason, just clean up and assume the test.
         IOUtils.closeWhileHandlingException(lock);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/core/src/test/org/apache/lucene/store/TestTrackingDirectoryWrapper.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/store/TestTrackingDirectoryWrapper.java b/lucene/core/src/test/org/apache/lucene/store/TestTrackingDirectoryWrapper.java
index 0985587..f9551d6 100644
--- a/lucene/core/src/test/org/apache/lucene/store/TestTrackingDirectoryWrapper.java
+++ b/lucene/core/src/test/org/apache/lucene/store/TestTrackingDirectoryWrapper.java
@@ -43,7 +43,7 @@ public class TestTrackingDirectoryWrapper extends BaseDirectoryTestCase {
     TrackingDirectoryWrapper dir = new TrackingDirectoryWrapper(new RAMDirectory());
     dir.createOutput("foo", newIOContext(random())).close();
     assertEquals(asSet("foo"), dir.getCreatedFiles());
-    dir.deleteFile("foo");
+    dir.deleteFiles(Collections.singleton("foo"));
     assertEquals(Collections.emptySet(), dir.getCreatedFiles());
   }
   

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/core/src/test/org/apache/lucene/util/TestOfflineSorter.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/util/TestOfflineSorter.java b/lucene/core/src/test/org/apache/lucene/util/TestOfflineSorter.java
index d8a878c..ca8e802 100644
--- a/lucene/core/src/test/org/apache/lucene/util/TestOfflineSorter.java
+++ b/lucene/core/src/test/org/apache/lucene/util/TestOfflineSorter.java
@@ -30,6 +30,7 @@ import org.apache.lucene.store.IOContext;
 import org.apache.lucene.store.IndexInput;
 import org.apache.lucene.store.IndexOutput;
 import org.apache.lucene.store.MockDirectoryWrapper;
+import org.apache.lucene.util.LuceneTestCase.SuppressFileSystems;
 import org.apache.lucene.util.OfflineSorter.BufferSize;
 import org.apache.lucene.util.OfflineSorter.ByteSequencesWriter;
 import org.apache.lucene.util.OfflineSorter.SortInfo;
@@ -37,6 +38,7 @@ import org.apache.lucene.util.OfflineSorter.SortInfo;
 /**
  * Tests for on-disk merge sorting.
  */
+@SuppressFileSystems("VirusCheckingFS")
 public class TestOfflineSorter extends LuceneTestCase {
   private Path tempDir;
 
@@ -54,30 +56,14 @@ public class TestOfflineSorter extends LuceneTestCase {
     super.tearDown();
   }
 
-  private static Directory newDirectoryNoVirusScanner() {
-    Directory dir = newDirectory();
-    if (dir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper) dir).setEnableVirusScanner(false);
-    }
-    return dir;
-  }
-
-  private static Directory newFSDirectoryNoVirusScanner() {
-    Directory dir = newFSDirectory(createTempDir());
-    if (dir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper) dir).setEnableVirusScanner(false);
-    }
-    return dir;
-  }
-
   public void testEmpty() throws Exception {
-    try (Directory dir = newDirectoryNoVirusScanner()) {
+    try (Directory dir = newDirectory()) {
         checkSort(dir, new OfflineSorter(dir, "foo"), new byte [][] {});
     }
   }
 
   public void testSingleLine() throws Exception {
-    try (Directory dir = newDirectoryNoVirusScanner()) {
+    try (Directory dir = newDirectory()) {
       checkSort(dir, new OfflineSorter(dir, "foo"), new byte [][] {
           "Single line only.".getBytes(StandardCharsets.UTF_8)
         });
@@ -86,7 +72,7 @@ public class TestOfflineSorter extends LuceneTestCase {
 
   public void testIntermediateMerges() throws Exception {
     // Sort 20 mb worth of data with 1mb buffer, binary merging.
-    try (Directory dir = newDirectoryNoVirusScanner()) {
+    try (Directory dir = newDirectory()) {
       SortInfo info = checkSort(dir, new OfflineSorter(dir, "foo", OfflineSorter.DEFAULT_COMPARATOR, BufferSize.megabytes(1), 2), 
           generateRandom((int)OfflineSorter.MB * 20));
       assertTrue(info.mergeRounds > 10);
@@ -95,7 +81,7 @@ public class TestOfflineSorter extends LuceneTestCase {
 
   public void testSmallRandom() throws Exception {
     // Sort 20 mb worth of data with 1mb buffer.
-    try (Directory dir = newDirectoryNoVirusScanner()) {
+    try (Directory dir = newDirectory()) {
       SortInfo sortInfo = checkSort(dir, new OfflineSorter(dir, "foo", OfflineSorter.DEFAULT_COMPARATOR, BufferSize.megabytes(1), OfflineSorter.MAX_TEMPFILES),
                                     generateRandom((int)OfflineSorter.MB * 20));
       assertEquals(1, sortInfo.mergeRounds);
@@ -105,7 +91,7 @@ public class TestOfflineSorter extends LuceneTestCase {
   @Nightly
   public void testLargerRandom() throws Exception {
     // Sort 100MB worth of data with 15mb buffer.
-    try (Directory dir = newFSDirectoryNoVirusScanner()) {
+    try (Directory dir = newFSDirectory(createTempDir())) {
       checkSort(dir, new OfflineSorter(dir, "foo", OfflineSorter.DEFAULT_COMPARATOR, BufferSize.megabytes(16), OfflineSorter.MAX_TEMPFILES), 
                 generateRandom((int)OfflineSorter.MB * 100));
     }
@@ -223,7 +209,7 @@ public class TestOfflineSorter extends LuceneTestCase {
     Thread[] threads = new Thread[TestUtil.nextInt(random(), 4, 10)];
     final AtomicBoolean failed = new AtomicBoolean();
     final int iters = atLeast(1000);
-    try (Directory dir = newDirectoryNoVirusScanner()) {
+    try (Directory dir = newDirectory()) {
       for(int i=0;i<threads.length;i++) {
         final int threadID = i;
         threads[i] = new Thread() {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/core/src/test/org/apache/lucene/util/bkd/TestBKD.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/util/bkd/TestBKD.java b/lucene/core/src/test/org/apache/lucene/util/bkd/TestBKD.java
index 3448150..dc17f96 100644
--- a/lucene/core/src/test/org/apache/lucene/util/bkd/TestBKD.java
+++ b/lucene/core/src/test/org/apache/lucene/util/bkd/TestBKD.java
@@ -22,6 +22,7 @@ import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.BitSet;
+import java.util.Collections;
 import java.util.List;
 
 import org.apache.lucene.index.PointValues.IntersectVisitor;
@@ -394,9 +395,6 @@ public class TestBKD extends LuceneTestCase {
         try {
           dir.setRandomIOExceptionRate(0.05);
           dir.setRandomIOExceptionRateOnOpen(0.05);
-          if (dir instanceof MockDirectoryWrapper) {
-            dir.setEnableVirusScanner(false);
-          }
           verify(dir, docValues, null, numDims, numBytesPerDim, 50, maxMBHeap);
         } catch (IllegalArgumentException iae) {
           // This just means we got a too-small maxMB for the maxPointsInLeafNode; just retry w/ more heap
@@ -820,9 +818,9 @@ public class TestBKD extends LuceneTestCase {
         }
       }
       in.close();
-      dir.deleteFile("bkd");
+      dir.deleteFiles(Collections.singleton("bkd"));
       if (toMerge != null) {
-        dir.deleteFile("bkd2");
+        dir.deleteFiles(Collections.singleton("bkd2"));
       }
       success = true;
     } finally {
@@ -848,9 +846,6 @@ public class TestBKD extends LuceneTestCase {
     } else {
       dir = newDirectory();
     }
-    if (dir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper) dir).setEnableVirusScanner(false);
-    }
     return dir;
   }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/core/src/test/org/apache/lucene/util/fst/Test2BFST.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/util/fst/Test2BFST.java b/lucene/core/src/test/org/apache/lucene/util/fst/Test2BFST.java
index 57d8374..e3868e4 100644
--- a/lucene/core/src/test/org/apache/lucene/util/fst/Test2BFST.java
+++ b/lucene/core/src/test/org/apache/lucene/util/fst/Test2BFST.java
@@ -18,6 +18,7 @@ package org.apache.lucene.util.fst;
  */
 
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.Random;
 
 import org.apache.lucene.store.Directory;
@@ -31,6 +32,7 @@ import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.TimeUnits;
 import org.apache.lucene.util.packed.PackedInts;
 import org.junit.Ignore;
+
 import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
 
 @Ignore("Requires tons of heap to run (30 GB hits OOME but 35 GB passes after ~4.5 hours)")
@@ -126,7 +128,7 @@ public class Test2BFST extends LuceneTestCase {
             fst = new FST<>(in, outputs);
             in.close();
           } else {
-            dir.deleteFile("fst");
+            dir.deleteFiles(Collections.singleton("fst"));
           }
         }
       }
@@ -203,7 +205,7 @@ public class Test2BFST extends LuceneTestCase {
             fst = new FST<>(in, outputs);
             in.close();
           } else {
-            dir.deleteFile("fst");
+            dir.deleteFiles(Collections.singleton("fst"));
           }
         }
       }
@@ -287,7 +289,7 @@ public class Test2BFST extends LuceneTestCase {
             fst = new FST<>(in, outputs);
             in.close();
           } else {
-            dir.deleteFile("fst");
+            dir.deleteFiles(Collections.singleton("fst"));
           }
         }
       }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java b/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java
index 27dd169..ac948d7 100644
--- a/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java
+++ b/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java
@@ -66,10 +66,11 @@ import org.apache.lucene.util.IntsRefBuilder;
 import org.apache.lucene.util.LineFileDocs;
 import org.apache.lucene.util.LuceneTestCase.Slow;
 import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
+import org.apache.lucene.util.LuceneTestCase.SuppressFileSystems;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.TestUtil;
-import org.apache.lucene.util.automaton.CompiledAutomaton;
 import org.apache.lucene.util.automaton.Automaton;
+import org.apache.lucene.util.automaton.CompiledAutomaton;
 import org.apache.lucene.util.automaton.RegExp;
 import org.apache.lucene.util.fst.BytesRefFSTEnum.InputOutput;
 import org.apache.lucene.util.fst.FST.Arc;
@@ -83,6 +84,7 @@ import static org.apache.lucene.util.fst.FSTTester.simpleRandomString;
 import static org.apache.lucene.util.fst.FSTTester.toIntsRef;
 
 @SuppressCodecs({ "SimpleText", "Memory", "Direct" })
+@SuppressFileSystems({ "VirusCheckingFS" })
 @Slow
 public class TestFSTs extends LuceneTestCase {
 
@@ -93,7 +95,6 @@ public class TestFSTs extends LuceneTestCase {
     super.setUp();
     dir = newMockDirectory();
     dir.setPreventDoubleWrite(false);
-    dir.setEnableVirusScanner(false);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/core/src/test/org/apache/lucene/util/packed/TestPackedInts.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/util/packed/TestPackedInts.java b/lucene/core/src/test/org/apache/lucene/util/packed/TestPackedInts.java
index bab144b..e11cfef 100644
--- a/lucene/core/src/test/org/apache/lucene/util/packed/TestPackedInts.java
+++ b/lucene/core/src/test/org/apache/lucene/util/packed/TestPackedInts.java
@@ -22,6 +22,7 @@ import java.nio.ByteBuffer;
 import java.nio.LongBuffer;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import java.util.Locale;
 import java.util.Random;
@@ -840,7 +841,7 @@ public class TestPackedInts extends LuceneTestCase {
           assertEquals(mutable.get(i), reader.get(i));
         }
         in.close();
-        directory.deleteFile("packed-ints.bin");
+        directory.deleteFiles(Collections.singleton("packed-ints.bin"));
       }
       directory.close();
     }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/misc/src/test/org/apache/lucene/util/fst/TestFSTsMisc.java
----------------------------------------------------------------------
diff --git a/lucene/misc/src/test/org/apache/lucene/util/fst/TestFSTsMisc.java b/lucene/misc/src/test/org/apache/lucene/util/fst/TestFSTsMisc.java
index 9ffa011..970d2ed 100644
--- a/lucene/misc/src/test/org/apache/lucene/util/fst/TestFSTsMisc.java
+++ b/lucene/misc/src/test/org/apache/lucene/util/fst/TestFSTsMisc.java
@@ -46,7 +46,6 @@ public class TestFSTsMisc extends LuceneTestCase {
     super.setUp();
     dir = newMockDirectory();
     dir.setPreventDoubleWrite(false);
-    dir.setEnableVirusScanner(false);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyReplicationClientTest.java
----------------------------------------------------------------------
diff --git a/lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyReplicationClientTest.java b/lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyReplicationClientTest.java
index 310399f..51ebae6 100644
--- a/lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyReplicationClientTest.java
+++ b/lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyReplicationClientTest.java
@@ -22,6 +22,7 @@ import java.io.Closeable;
 import java.io.IOException;
 import java.io.PrintStream;
 import java.nio.file.Path;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.concurrent.Callable;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -424,22 +425,6 @@ public class IndexAndTaxonomyReplicationClientTest extends ReplicatorTestCase {
               }
             }
 
-            if (indexStatus == null || indexStatus.clean == false) {
-
-              // Because segments file for taxo index is replicated after
-              // main index's segments file, if there's an error while replicating
-              // main index's segments file and if virus checker prevents
-              // deletion of taxo index's segments file, it can look like corruption.
-              // But it should be "false" meaning if we remove the latest segments
-              // file then the index is intact.  It's like pulling a hideous
-              // looking rock out of the ground, but then you pull the cruft
-              // off the outside of it and discover it's actually a beautiful
-              // diamond:
-              String segmentsFileName = SegmentInfos.getLastCommitSegmentsFileName(handlerTaxoDir);
-              assertTrue(handlerTaxoDir.didTryToDelete(segmentsFileName));
-              handlerTaxoDir.getDelegate().deleteFile(segmentsFileName);
-              TestUtil.checkIndex(handlerTaxoDir.getDelegate());
-            }
           } catch (IOException e) {
             failed.set(true);
             throw new RuntimeException(e);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyRevisionTest.java
----------------------------------------------------------------------
diff --git a/lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyRevisionTest.java b/lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyRevisionTest.java
index 2c832da..7a4465a 100644
--- a/lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyRevisionTest.java
+++ b/lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyRevisionTest.java
@@ -77,10 +77,6 @@ public class IndexAndTaxonomyRevisionTest extends ReplicatorTestCase {
     
     Directory taxoDir = newDirectory();
     SnapshotDirectoryTaxonomyWriter taxoWriter = new SnapshotDirectoryTaxonomyWriter(taxoDir);
-    // we look to see that certain files are deleted:
-    if (indexDir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper)indexDir).setEnableVirusScanner(false);
-    }
     try {
       indexWriter.addDocument(newDocument(taxoWriter));
       indexWriter.commit();
@@ -101,10 +97,6 @@ public class IndexAndTaxonomyRevisionTest extends ReplicatorTestCase {
       indexWriter.close();
     } finally {
       IOUtils.close(indexWriter, taxoWriter, taxoDir, indexDir);
-      if (indexDir instanceof MockDirectoryWrapper) {
-        // set back to on for other tests
-        ((MockDirectoryWrapper)indexDir).setEnableVirusScanner(true);
-      }
     }
   }
   

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/replicator/src/test/org/apache/lucene/replicator/IndexRevisionTest.java
----------------------------------------------------------------------
diff --git a/lucene/replicator/src/test/org/apache/lucene/replicator/IndexRevisionTest.java b/lucene/replicator/src/test/org/apache/lucene/replicator/IndexRevisionTest.java
index 6ebdd15..9e267ab 100644
--- a/lucene/replicator/src/test/org/apache/lucene/replicator/IndexRevisionTest.java
+++ b/lucene/replicator/src/test/org/apache/lucene/replicator/IndexRevisionTest.java
@@ -73,10 +73,6 @@ public class IndexRevisionTest extends ReplicatorTestCase {
   @Test
   public void testRevisionRelease() throws Exception {
     Directory dir = newDirectory();
-    // we look to see that certain files are deleted:
-    if (dir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper)dir).setEnableVirusScanner(false);
-    }
     IndexWriterConfig conf = new IndexWriterConfig(null);
     conf.setIndexDeletionPolicy(new SnapshotDeletionPolicy(conf.getIndexDeletionPolicy()));
     IndexWriter writer = new IndexWriter(dir, conf);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/replicator/src/test/org/apache/lucene/replicator/LocalReplicatorTest.java
----------------------------------------------------------------------
diff --git a/lucene/replicator/src/test/org/apache/lucene/replicator/LocalReplicatorTest.java b/lucene/replicator/src/test/org/apache/lucene/replicator/LocalReplicatorTest.java
index 3c9a8d1..b092e83 100644
--- a/lucene/replicator/src/test/org/apache/lucene/replicator/LocalReplicatorTest.java
+++ b/lucene/replicator/src/test/org/apache/lucene/replicator/LocalReplicatorTest.java
@@ -119,57 +119,35 @@ public class LocalReplicatorTest extends ReplicatorTestCase {
   
   @Test
   public void testPublishSameRevision() throws IOException {
-    // we look to see that certain files are deleted:
-    if (sourceDir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper)sourceDir).setEnableVirusScanner(false);
-    }
-    try {
-      Revision rev = createRevision(1);
-      replicator.publish(rev);
-      SessionToken res = replicator.checkForUpdate(null);
-      assertNotNull(res);
-      assertEquals(rev.getVersion(), res.version);
-      replicator.release(res.id);
-      replicator.publish(new IndexRevision(sourceWriter));
-      res = replicator.checkForUpdate(res.version);
-      assertNull(res);
+    Revision rev = createRevision(1);
+    replicator.publish(rev);
+    SessionToken res = replicator.checkForUpdate(null);
+    assertNotNull(res);
+    assertEquals(rev.getVersion(), res.version);
+    replicator.release(res.id);
+    replicator.publish(new IndexRevision(sourceWriter));
+    res = replicator.checkForUpdate(res.version);
+    assertNull(res);
       
-      // now make sure that publishing same revision doesn't leave revisions
-      // "locked", i.e. that replicator releases revisions even when they are not
-      // kept
-      replicator.publish(createRevision(2));
-      assertEquals(1, DirectoryReader.listCommits(sourceDir).size());
-    } finally {
-      if (sourceDir instanceof MockDirectoryWrapper) {
-        // set back to on for other tests
-        ((MockDirectoryWrapper)sourceDir).setEnableVirusScanner(true);
-      }
-    }
+    // now make sure that publishing same revision doesn't leave revisions
+    // "locked", i.e. that replicator releases revisions even when they are not
+    // kept
+    replicator.publish(createRevision(2));
+    assertEquals(1, DirectoryReader.listCommits(sourceDir).size());
   }
   
   @Test
   public void testPublishOlderRev() throws IOException {
-    // we look to see that certain files are deleted:
-    if (sourceDir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper)sourceDir).setEnableVirusScanner(false);
-    }
+    replicator.publish(createRevision(1));
+    Revision old = new IndexRevision(sourceWriter);
+    replicator.publish(createRevision(2));
     try {
-      replicator.publish(createRevision(1));
-      Revision old = new IndexRevision(sourceWriter);
-      replicator.publish(createRevision(2));
-      try {
-        replicator.publish(old);
-        fail("should have failed to publish an older revision");
-      } catch (IllegalArgumentException e) {
-        // expected
-      }
-      assertEquals(1, DirectoryReader.listCommits(sourceDir).size());
-    } finally {
-      if (sourceDir instanceof MockDirectoryWrapper) {
-        // set back to on for other tests
-        ((MockDirectoryWrapper)sourceDir).setEnableVirusScanner(true);
-      }
+      replicator.publish(old);
+      fail("should have failed to publish an older revision");
+    } catch (IllegalArgumentException e) {
+      // expected
     }
+    assertEquals(1, DirectoryReader.listCommits(sourceDir).size());
   }
   
   @Test
@@ -210,24 +188,12 @@ public class LocalReplicatorTest extends ReplicatorTestCase {
   
   @Test
   public void testRevisionRelease() throws Exception {
-    // we look to see that certain files are deleted:
-    if (sourceDir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper)sourceDir).setEnableVirusScanner(false);
-    }
-    
-    try {
-      replicator.publish(createRevision(1));
-      assertTrue(slowFileExists(sourceDir, IndexFileNames.SEGMENTS + "_1"));
-      replicator.publish(createRevision(2));
-      // now the files of revision 1 can be deleted
-      assertTrue(slowFileExists(sourceDir, IndexFileNames.SEGMENTS + "_2"));
-      assertFalse("segments_1 should not be found in index directory after revision is released", slowFileExists(sourceDir, IndexFileNames.SEGMENTS + "_1"));
-    } finally {
-      if (sourceDir instanceof MockDirectoryWrapper) {
-        // set back to on for other tests
-        ((MockDirectoryWrapper)sourceDir).setEnableVirusScanner(true);
-      }
-    }
+    replicator.publish(createRevision(1));
+    assertTrue(slowFileExists(sourceDir, IndexFileNames.SEGMENTS + "_1"));
+    replicator.publish(createRevision(2));
+    // now the files of revision 1 can be deleted
+    assertTrue(slowFileExists(sourceDir, IndexFileNames.SEGMENTS + "_2"));
+    assertFalse("segments_1 should not be found in index directory after revision is released", slowFileExists(sourceDir, IndexFileNames.SEGMENTS + "_1"));
   }
   
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/sandbox/src/test/org/apache/lucene/util/BaseGeoPointTestCase.java
----------------------------------------------------------------------
diff --git a/lucene/sandbox/src/test/org/apache/lucene/util/BaseGeoPointTestCase.java b/lucene/sandbox/src/test/org/apache/lucene/util/BaseGeoPointTestCase.java
index 42adeab..fa9ea00 100644
--- a/lucene/sandbox/src/test/org/apache/lucene/util/BaseGeoPointTestCase.java
+++ b/lucene/sandbox/src/test/org/apache/lucene/util/BaseGeoPointTestCase.java
@@ -213,7 +213,6 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
     double[] lats = new double[2*numPoints];
     double[] lons = new double[2*numPoints];
     Directory dir = newDirectory();
-    noVirusChecker(dir);
     IndexWriterConfig iwc = newIndexWriterConfig();
     initIndexWriterConfig(FIELD_NAME, iwc);
 
@@ -560,7 +559,6 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
     } else {
       dir = newDirectory();
     }
-    noVirusChecker(dir);
 
     Set<Integer> deleted = new HashSet<>();
     // RandomIndexWriter is too slow here:
@@ -755,11 +753,4 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
     IOUtils.close(r, dir);
     assertFalse(failed.get());
   }
-
-  protected Directory noVirusChecker(Directory dir) {
-    if (dir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper) dir).setEnableVirusScanner(false);
-    }
-    return dir;
-  }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/spatial3d/src/test/org/apache/lucene/geo3d/TestGeo3DPoint.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/test/org/apache/lucene/geo3d/TestGeo3DPoint.java b/lucene/spatial3d/src/test/org/apache/lucene/geo3d/TestGeo3DPoint.java
index 0b7a5de..edf2a1a 100644
--- a/lucene/spatial3d/src/test/org/apache/lucene/geo3d/TestGeo3DPoint.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/geo3d/TestGeo3DPoint.java
@@ -651,7 +651,7 @@ public class TestGeo3DPoint extends LuceneTestCase {
     iwc.setCodec(getCodec());
     Directory dir;
     if (lats.length > 100000) {
-      dir = noVirusChecker(newFSDirectory(createTempDir("TestBKDTree")));
+      dir = newFSDirectory(createTempDir("TestBKDTree"));
     } else {
       dir = getDirectory();
     }
@@ -789,14 +789,7 @@ public class TestGeo3DPoint extends LuceneTestCase {
     IOUtils.close(r, dir);
   }
 
-  private static Directory noVirusChecker(Directory dir) {
-    if (dir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper) dir).setEnableVirusScanner(false);
-    }
-    return dir;
-  }
-
   private static Directory getDirectory() {     
-    return noVirusChecker(newDirectory());
+    return newDirectory();
   }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggester.java
----------------------------------------------------------------------
diff --git a/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggester.java b/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggester.java
index f54ad03..cb2d38c 100644
--- a/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggester.java
+++ b/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggester.java
@@ -487,7 +487,7 @@ public class AnalyzingSuggester extends Lookup implements Accountable {
       tempSortedFileName = sorter.sort(tempInput.getName());
 
       // Free disk space:
-      tempDir.deleteFile(tempInput.getName());
+      tempDir.deleteFiles(Collections.singleton(tempInput.getName()));
 
       reader = new OfflineSorter.ByteSequencesReader(tempDir.openInput(tempSortedFileName, IOContext.READONCE));
      

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/suggest/src/java/org/apache/lucene/search/suggest/fst/ExternalRefSorter.java
----------------------------------------------------------------------
diff --git a/lucene/suggest/src/java/org/apache/lucene/search/suggest/fst/ExternalRefSorter.java b/lucene/suggest/src/java/org/apache/lucene/search/suggest/fst/ExternalRefSorter.java
index e07a68c..132c630 100644
--- a/lucene/suggest/src/java/org/apache/lucene/search/suggest/fst/ExternalRefSorter.java
+++ b/lucene/suggest/src/java/org/apache/lucene/search/suggest/fst/ExternalRefSorter.java
@@ -19,6 +19,7 @@ package org.apache.lucene.search.suggest.fst;
 
 import java.io.Closeable;
 import java.io.IOException;
+import java.util.Collections;
 import java.util.Comparator;
 
 import org.apache.lucene.store.IOContext;
@@ -68,7 +69,7 @@ public class ExternalRefSorter implements BytesRefSorter, Closeable {
         success = true;
       } finally {
         if (success) {
-          sorter.getDirectory().deleteFile(input.getName());
+          sorter.getDirectory().deleteFiles(Collections.singleton(input.getName()));
         } else {
           IOUtils.deleteFilesIgnoringExceptions(sorter.getDirectory(), input.getName());
         }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/suggest/src/java/org/apache/lucene/search/suggest/fst/FSTCompletionLookup.java
----------------------------------------------------------------------
diff --git a/lucene/suggest/src/java/org/apache/lucene/search/suggest/fst/FSTCompletionLookup.java b/lucene/suggest/src/java/org/apache/lucene/search/suggest/fst/FSTCompletionLookup.java
index 24dd0f9..d178aa4 100644
--- a/lucene/suggest/src/java/org/apache/lucene/search/suggest/fst/FSTCompletionLookup.java
+++ b/lucene/suggest/src/java/org/apache/lucene/search/suggest/fst/FSTCompletionLookup.java
@@ -204,7 +204,7 @@ public class FSTCompletionLookup extends Lookup implements Accountable {
       // We don't know the distribution of scores and we need to bucket them, so we'll sort
       // and divide into equal buckets.
       tempSortedFileName = sorter.sort(tempInput.getName());
-      tempDir.deleteFile(tempInput.getName());
+      tempDir.deleteFiles(Collections.singleton(tempInput.getName()));
 
       FSTCompletionBuilder builder = new FSTCompletionBuilder(
           buckets, externalSorter, sharedTailLength);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/suggest/src/test/org/apache/lucene/search/suggest/PersistenceTest.java
----------------------------------------------------------------------
diff --git a/lucene/suggest/src/test/org/apache/lucene/search/suggest/PersistenceTest.java b/lucene/suggest/src/test/org/apache/lucene/search/suggest/PersistenceTest.java
index 35c5f25..ea0394b 100644
--- a/lucene/suggest/src/test/org/apache/lucene/search/suggest/PersistenceTest.java
+++ b/lucene/suggest/src/test/org/apache/lucene/search/suggest/PersistenceTest.java
@@ -61,11 +61,7 @@ public class PersistenceTest extends LuceneTestCase {
   }
 
   private Directory getDirectory() {     
-    Directory dir = newDirectory();
-    if (dir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper) dir).setEnableVirusScanner(false);
-    }
-    return dir;
+    return newDirectory();
   }
 
   private void runTest(Class<? extends Lookup> lookupClass, boolean supportsExactWeights) throws Exception {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/suggest/src/test/org/apache/lucene/search/suggest/TestInputIterator.java
----------------------------------------------------------------------
diff --git a/lucene/suggest/src/test/org/apache/lucene/search/suggest/TestInputIterator.java b/lucene/suggest/src/test/org/apache/lucene/search/suggest/TestInputIterator.java
index 55e70bd..050593e 100644
--- a/lucene/suggest/src/test/org/apache/lucene/search/suggest/TestInputIterator.java
+++ b/lucene/suggest/src/test/org/apache/lucene/search/suggest/TestInputIterator.java
@@ -171,10 +171,6 @@ public class TestInputIterator extends LuceneTestCase {
   }
 
   private Directory getDirectory() {     
-    Directory dir = newDirectory();
-    if (dir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper) dir).setEnableVirusScanner(false);
-    }
-    return dir;
+    return newDirectory();
   }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java
----------------------------------------------------------------------
diff --git a/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java b/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java
index a9c7acc..1d0891b 100644
--- a/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java
+++ b/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java
@@ -1268,10 +1268,6 @@ public class AnalyzingSuggesterTest extends LuceneTestCase {
   }
 
   private Directory getDirectory() {     
-    Directory dir = newDirectory();
-    if (dir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper) dir).setEnableVirusScanner(false);
-    }
-    return dir;
+    return newDirectory();
   }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/FuzzySuggesterTest.java
----------------------------------------------------------------------
diff --git a/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/FuzzySuggesterTest.java b/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/FuzzySuggesterTest.java
index 47c19e1..9fbbba3 100644
--- a/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/FuzzySuggesterTest.java
+++ b/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/FuzzySuggesterTest.java
@@ -1213,10 +1213,6 @@ public class FuzzySuggesterTest extends LuceneTestCase {
   }
 
   private Directory getDirectory() {     
-    Directory dir = newDirectory();
-    if (dir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper) dir).setEnableVirusScanner(false);
-    }
-    return dir;
+    return newDirectory();
   }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/suggest/src/test/org/apache/lucene/search/suggest/fst/BytesRefSortersTest.java
----------------------------------------------------------------------
diff --git a/lucene/suggest/src/test/org/apache/lucene/search/suggest/fst/BytesRefSortersTest.java b/lucene/suggest/src/test/org/apache/lucene/search/suggest/fst/BytesRefSortersTest.java
index ce332ce..7dec5fb 100644
--- a/lucene/suggest/src/test/org/apache/lucene/search/suggest/fst/BytesRefSortersTest.java
+++ b/lucene/suggest/src/test/org/apache/lucene/search/suggest/fst/BytesRefSortersTest.java
@@ -31,9 +31,6 @@ public class BytesRefSortersTest extends LuceneTestCase {
   @Test
   public void testExternalRefSorter() throws Exception {
     Directory tempDir = newDirectory();
-    if (tempDir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper) tempDir).setEnableVirusScanner(false);
-    }
     ExternalRefSorter s = new ExternalRefSorter(new OfflineSorter(tempDir, "temp"));
     check(s);
     IOUtils.close(s, tempDir);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/suggest/src/test/org/apache/lucene/search/suggest/fst/FSTCompletionTest.java
----------------------------------------------------------------------
diff --git a/lucene/suggest/src/test/org/apache/lucene/search/suggest/fst/FSTCompletionTest.java b/lucene/suggest/src/test/org/apache/lucene/search/suggest/fst/FSTCompletionTest.java
index bddb306..63d108c 100644
--- a/lucene/suggest/src/test/org/apache/lucene/search/suggest/fst/FSTCompletionTest.java
+++ b/lucene/suggest/src/test/org/apache/lucene/search/suggest/fst/FSTCompletionTest.java
@@ -273,10 +273,6 @@ public class FSTCompletionTest extends LuceneTestCase {
   }
 
   private Directory getDirectory() {     
-    Directory dir = newDirectory();
-    if (dir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper) dir).setEnableVirusScanner(false);
-    }
-    return dir;
+    return newDirectory();
   }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/suggest/src/test/org/apache/lucene/search/suggest/fst/WFSTCompletionTest.java
----------------------------------------------------------------------
diff --git a/lucene/suggest/src/test/org/apache/lucene/search/suggest/fst/WFSTCompletionTest.java b/lucene/suggest/src/test/org/apache/lucene/search/suggest/fst/WFSTCompletionTest.java
index c213c4b..2c53ac4 100644
--- a/lucene/suggest/src/test/org/apache/lucene/search/suggest/fst/WFSTCompletionTest.java
+++ b/lucene/suggest/src/test/org/apache/lucene/search/suggest/fst/WFSTCompletionTest.java
@@ -236,10 +236,6 @@ public class WFSTCompletionTest extends LuceneTestCase {
   }
 
   private Directory getDirectory() {     
-    Directory dir = newDirectory();
-    if (dir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper) dir).setEnableVirusScanner(false);
-    }
-    return dir;
+    return newDirectory();
   }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompoundFormatTestCase.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompoundFormatTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompoundFormatTestCase.java
index 9122e99..0c40bb3 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompoundFormatTestCase.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompoundFormatTestCase.java
@@ -183,11 +183,6 @@ public abstract class BaseCompoundFormatTestCase extends BaseIndexFileFormatTest
   // Just tests that we can open all files returned by listAll
   public void testListAll() throws Exception {
     Directory dir = newDirectory();
-    if (dir instanceof MockDirectoryWrapper) {
-      // test lists files manually and tries to verify every .cfs it finds,
-      // but a virus scanner could leave some trash.
-      ((MockDirectoryWrapper)dir).setEnableVirusScanner(false);
-    }
     // riw should sometimes create docvalues fields, etc
     RandomIndexWriter riw = new RandomIndexWriter(random(), dir);
     Document doc = new Document();
@@ -252,7 +247,7 @@ public abstract class BaseCompoundFormatTestCase extends BaseIndexFileFormatTest
     si.getCodec().compoundFormat().write(dir, si, IOContext.DEFAULT);
     Directory cfs = si.getCodec().compoundFormat().getCompoundReader(dir, si, IOContext.DEFAULT);
     try {
-      cfs.deleteFile(testfile);
+      cfs.deleteFiles(Collections.singleton(testfile));
       fail("didn't get expected exception");
     } catch (UnsupportedOperationException expected) {
       // expected UOE

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/test-framework/src/java/org/apache/lucene/index/BaseIndexFileFormatTestCase.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/BaseIndexFileFormatTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/index/BaseIndexFileFormatTestCase.java
index c53293c..9409c47 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/index/BaseIndexFileFormatTestCase.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/index/BaseIndexFileFormatTestCase.java
@@ -197,11 +197,7 @@ abstract class BaseIndexFileFormatTestCase extends LuceneTestCase {
   public void testMergeStability() throws Exception {
     assumeTrue("merge is not stable", mergeIsStable());
     Directory dir = newDirectory();
-    if (dir instanceof MockDirectoryWrapper) {
-      // Else, the virus checker may prevent deletion of files and cause
-      // us to see too many bytes used by extension in the end:
-      ((MockDirectoryWrapper) dir).setEnableVirusScanner(false);
-    }
+
     // do not use newMergePolicy that might return a MockMergePolicy that ignores the no-CFS ratio
     // do not use RIW which will change things up!
     MergePolicy mp = newTieredMergePolicy();
@@ -220,11 +216,6 @@ abstract class BaseIndexFileFormatTestCase extends LuceneTestCase {
     DirectoryReader reader = DirectoryReader.open(dir);
 
     Directory dir2 = newDirectory();
-    if (dir2 instanceof MockDirectoryWrapper) {
-      // Else, the virus checker may prevent deletion of files and cause
-      // us to see too many bytes used by extension in the end:
-      ((MockDirectoryWrapper) dir2).setEnableVirusScanner(false);
-    }
     mp = newTieredMergePolicy();
     mp.setNoCFSRatio(0);
     cfg = new IndexWriterConfig(new MockAnalyzer(random())).setUseCompoundFile(false).setMergePolicy(mp);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/test-framework/src/java/org/apache/lucene/index/BasePointFormatTestCase.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/BasePointFormatTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/index/BasePointFormatTestCase.java
index 2b88d74..9a58f77 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/index/BasePointFormatTestCase.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/index/BasePointFormatTestCase.java
@@ -216,9 +216,6 @@ public abstract class BasePointFormatTestCase extends BaseIndexFileFormatTestCas
         try {
           dir.setRandomIOExceptionRate(0.05);
           dir.setRandomIOExceptionRateOnOpen(0.05);
-          if (dir instanceof MockDirectoryWrapper) {
-            dir.setEnableVirusScanner(false);
-          }
           verify(dir, docValues, null, numDims, numBytesPerDim, true);
         } catch (IllegalStateException ise) {
           if (ise.getMessage().contains("this writer hit an unrecoverable error")) {
@@ -901,13 +898,6 @@ public abstract class BasePointFormatTestCase extends BaseIndexFileFormatTestCas
     return x;
   }
 
-  private static Directory noVirusChecker(Directory dir) {
-    if (dir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper) dir).setEnableVirusScanner(false);
-    }
-    return dir;
-  }
-
   private Directory getDirectory(int numPoints) throws IOException {
     Directory dir;
     if (numPoints > 100000) {
@@ -915,7 +905,6 @@ public abstract class BasePointFormatTestCase extends BaseIndexFileFormatTestCas
     } else {
       dir = newDirectory();
     }
-    noVirusChecker(dir);
     //dir = FSDirectory.open(createTempDir());
     return dir;
   }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java
index e6dd26e..914cd6d 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java
@@ -145,7 +145,6 @@ public abstract class BasePostingsFormatTestCase extends BaseIndexFileFormatTest
       fieldsProducer = null;
 
       dir.close();
-      IOUtils.rm(path);
     }
   }
 
@@ -172,7 +171,6 @@ public abstract class BasePostingsFormatTestCase extends BaseIndexFileFormatTest
 
     fieldsProducer.close();
     dir.close();
-    IOUtils.rm(path);
   }
 
   protected static void checkReuse(TermsEnum termsEnum, int firstFlags, int secondFlags, boolean shouldReuse) throws IOException {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/test-framework/src/java/org/apache/lucene/index/RandomPostingsTester.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/RandomPostingsTester.java b/lucene/test-framework/src/java/org/apache/lucene/index/RandomPostingsTester.java
index 27ba502..fe09389 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/index/RandomPostingsTester.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/index/RandomPostingsTester.java
@@ -1271,6 +1271,5 @@ public class RandomPostingsTester {
 
     fieldsProducer.close();
     dir.close();
-    IOUtils.rm(path);
   }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/test-framework/src/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java
index 3d6e43c..894086f 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java
@@ -654,7 +654,6 @@ public abstract class ThreadedIndexingAndSearchingTestCase extends LuceneTestCas
 
     TestUtil.checkIndex(dir);
     dir.close();
-    IOUtils.rm(tempDir);
 
     if (VERBOSE) {
       System.out.println("TEST: done [" + (System.currentTimeMillis()-t0) + " ms]");

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/test-framework/src/java/org/apache/lucene/mockfile/VirusCheckingFS.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/mockfile/VirusCheckingFS.java b/lucene/test-framework/src/java/org/apache/lucene/mockfile/VirusCheckingFS.java
new file mode 100644
index 0000000..801a688
--- /dev/null
+++ b/lucene/test-framework/src/java/org/apache/lucene/mockfile/VirusCheckingFS.java
@@ -0,0 +1,65 @@
+package org.apache.lucene.mockfile;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+import java.nio.file.AccessDeniedException;
+import java.nio.file.FileSystem;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Random;
+
+import org.apache.lucene.index.IndexWriter;
+
+/** 
+ * Acts like Windows, where random programs may open the files you just wrote in an unfriendly
+ * way preventing deletion (e.g. not passing FILE_SHARE_DELETE) or renaming or overwriting etc.
+ */
+public class VirusCheckingFS extends FilterFileSystemProvider {
+
+  // nocommit cannot use random here
+  final Random random;
+
+  private boolean enabled = true;
+
+  /** 
+   * Create a new instance, wrapping {@code delegate}.
+   */
+  public VirusCheckingFS(FileSystem delegate, Random random) {
+    super("viruschecking://", delegate);
+    this.random = new Random(random.nextLong());
+  }
+
+  public void disable() {
+    enabled = false;
+  }
+
+  @Override
+  public void delete(Path path) throws IOException {
+    
+    if (enabled // test infra disables when it's "really" time to delete after test is done
+        && Files.exists(path) // important that we NOT delay a NoSuchFileException until later
+        && path.getFileName().toString().equals(IndexWriter.WRITE_LOCK_NAME) == false // life is particularly difficult if the virus checker hits our lock file
+        && random.nextInt(5) == 1) {
+      throw new AccessDeniedException("VirusCheckingFS is randomly refusing to delete file \"" + path + "\"");
+    }
+    super.delete(path);
+  }
+
+  // TODO: rename?  createOutput?  deleteIfExists?
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java
index c015351..db83153 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java
@@ -164,7 +164,7 @@ public abstract class BaseDirectoryTestCase extends LuceneTestCase {
     int count = dir.listAll().length;
     dir.createOutput("foo.txt", IOContext.DEFAULT).close();
     assertEquals(count+1, dir.listAll().length);
-    dir.deleteFile("foo.txt");
+    dir.deleteFiles(Collections.singleton("foo.txt"));
     assertEquals(count, dir.listAll().length);
     dir.close();
   }
@@ -668,6 +668,7 @@ public abstract class BaseDirectoryTestCase extends LuceneTestCase {
   // LUCENE-3382 -- make sure we get exception if the directory really does not exist.
   public void testNoDir() throws Throwable {
     Path tempDir = createTempDir("doesnotexist");
+    assumeFalse("test directly deletes files", TestUtil.hasVirusChecker(tempDir));
     IOUtils.rm(tempDir);
     Directory dir = getDirectory(tempDir);
     try {
@@ -750,9 +751,7 @@ public abstract class BaseDirectoryTestCase extends LuceneTestCase {
     }
     in2.close();
       
-    dir.deleteFile("test");
-    dir.deleteFile("test2");
-      
+    dir.deleteFiles(Arrays.asList(new String[] {"test", "test2"}));
     dir.close();
   }
   
@@ -827,6 +826,7 @@ public abstract class BaseDirectoryTestCase extends LuceneTestCase {
   // TODO: somehow change this test to 
   public void testFsyncDoesntCreateNewFiles() throws Exception {
     Path path = createTempDir("nocreate");
+    assumeFalse("we directly delete files", TestUtil.hasVirusChecker(path));
     Directory fsdir = getDirectory(path);
     
     // this test backdoors the directory via the filesystem. so it must be an FSDir (for now)
@@ -1185,7 +1185,7 @@ public abstract class BaseDirectoryTestCase extends LuceneTestCase {
       in.close();
     }
     Set<String> files = new HashSet<String>(Arrays.asList(dir.listAll()));
-    // In case ExtraFS struck:
+    // In case ExtrasFS struck:
     files.remove("extra0");
     assertEquals(new HashSet<String>(names), files);
     dir.close();

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/test-framework/src/java/org/apache/lucene/store/BaseLockFactoryTestCase.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/store/BaseLockFactoryTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/store/BaseLockFactoryTestCase.java
index 13bc0ff..5dfe3e8 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,6 +17,17 @@ 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.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;
+
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
@@ -32,17 +43,7 @@ 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;
+import org.apache.lucene.util.TestUtil;
 
 /** Base class for per-LockFactory tests. */
 public abstract class BaseLockFactoryTestCase extends LuceneTestCase {
@@ -54,7 +55,9 @@ public abstract class BaseLockFactoryTestCase extends LuceneTestCase {
   
   /** Test obtaining and releasing locks, checking validity */
   public void testBasics() throws IOException {
-    Directory dir = getDirectory(createTempDir());
+    Path tempPath = createTempDir();
+    assumeFalse("test works with lock files", TestUtil.hasVirusChecker(tempPath));
+    Directory dir = getDirectory(tempPath);
     
     Lock l = dir.obtainLock("commit");
     try {
@@ -72,7 +75,9 @@ public abstract class BaseLockFactoryTestCase extends LuceneTestCase {
   
   /** Test closing locks twice */
   public void testDoubleClose() throws IOException {
-    Directory dir = getDirectory(createTempDir());
+    Path tempPath = createTempDir();
+    assumeFalse("test works with lock files", TestUtil.hasVirusChecker(tempPath));
+    Directory dir = getDirectory(tempPath);
     
     Lock l = dir.obtainLock("commit");
     l.close();
@@ -83,18 +88,20 @@ public abstract class BaseLockFactoryTestCase extends LuceneTestCase {
   
   /** Test ensureValid returns true after acquire */
   public void testValidAfterAcquire() throws IOException {
-    Directory dir = getDirectory(createTempDir());
-
+    Path tempPath = createTempDir();
+    assumeFalse("test works with lock files", TestUtil.hasVirusChecker(tempPath));
+    Directory dir = getDirectory(tempPath);
     Lock l = dir.obtainLock("commit");
     l.ensureValid(); // no exception
     l.close();
-    
     dir.close();
   }
   
   /** Test ensureValid throws exception after close */
   public void testInvalidAfterClose() throws IOException {
-    Directory dir = getDirectory(createTempDir());
+    Path tempPath = createTempDir();
+    assumeFalse("test works with lock files", TestUtil.hasVirusChecker(tempPath));
+    Directory dir = getDirectory(tempPath);
     
     Lock l = dir.obtainLock("commit");
     l.close();
@@ -103,12 +110,13 @@ public abstract class BaseLockFactoryTestCase extends LuceneTestCase {
       l.ensureValid();
       fail("didn't get exception");
     } catch (AlreadyClosedException expected) {}
-    
     dir.close();
   }
   
   public void testObtainConcurrently() throws InterruptedException, IOException {
-    final Directory directory = getDirectory(createTempDir());
+    Path tempPath = createTempDir();
+    assumeFalse("test works with lock files", TestUtil.hasVirusChecker(tempPath));
+    final Directory directory = getDirectory(tempPath);
     final AtomicBoolean running = new AtomicBoolean(true);
     final AtomicInteger atomicCounter = new AtomicInteger(0);
     final ReentrantLock assertingLock = new ReentrantLock();
@@ -156,7 +164,9 @@ public abstract class BaseLockFactoryTestCase extends LuceneTestCase {
   // IndexWriters over & over in 2 threads and making sure
   // no unexpected exceptions are raised:
   public void testStressLocks() throws Exception {
-    Directory dir = getDirectory(createTempDir());
+    Path tempPath = createTempDir();
+    assumeFalse("test works with lock files", TestUtil.hasVirusChecker(tempPath));
+    Directory dir = getDirectory(tempPath);
 
     // First create a 1 doc index:
     IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(new MockAnalyzer(random())).setOpenMode(OpenMode.CREATE));

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java b/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java
index ec99c7e..3bd2319 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java
@@ -73,12 +73,10 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
   double randomIOExceptionRate;
   double randomIOExceptionRateOnOpen;
   Random randomState;
-  boolean noDeleteOpenFile = true;
   boolean assertNoDeleteOpenFile = false;
   boolean preventDoubleWrite = true;
   boolean trackDiskUsage = false;
   boolean useSlowOpenClosers = LuceneTestCase.TEST_NIGHTLY;
-  boolean enableVirusScanner = true;
   boolean allowRandomFileNotFoundException = true;
   boolean allowReadingFilesStillOpenForWrite = false;
   private Set<String> unSyncedFiles;
@@ -105,15 +103,10 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
   // is made to delete an open file, we enroll it here.
   private Set<String> openFilesDeleted;
   
-  // only tracked if virus scanner is enabled:
-  // set of files it prevented deletion for
-  private Set<String> triedToDelete;
-
   private synchronized void init() {
     if (openFiles == null) {
       openFiles = new HashMap<>();
       openFilesDeleted = new HashSet<>();
-      triedToDelete = new HashSet<>();
     }
 
     if (createdFiles == null)
@@ -171,18 +164,6 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
     allowReadingFilesStillOpenForWrite = value;
   }
   
-  /** Returns true if the virus scanner is enabled */
-  public boolean getEnableVirusScanner() {
-    return enableVirusScanner;
-  }
-  
-  /** If set to true (the default), deleteFile sometimes
-   *  fails because a virus scanner is open.
-   */
-  public void setEnableVirusScanner(boolean value) {
-    this.enableVirusScanner = value;
-  }
-
   /**
    * Enum for controlling hard disk throttling.
    * Set via {@link MockDirectoryWrapper #setThrottling(Throttling)}
@@ -237,12 +218,8 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
       throw new IOException("cannot rename after crash");
     }
     
-    if (openFiles.containsKey(source)) {
-      if (assertNoDeleteOpenFile) {
-        throw (AssertionError) fillOpenTrace(new AssertionError("MockDirectoryWrapper: file \"" + source + "\" is still open: cannot rename"), source, true);
-      } else if (noDeleteOpenFile) {
-        throw (IOException) fillOpenTrace(new IOException("MockDirectoryWrapper: file \"" + source + "\" is still open: cannot rename"), source, true);
-      }
+    if (assertNoDeleteOpenFile && openFiles.containsKey(source)) {
+      throw (AssertionError) fillOpenTrace(new AssertionError("MockDirectoryWrapper: file \"" + source + "\" is still open: cannot rename"), source, true);
     }
 
     boolean success = false;
@@ -281,7 +258,6 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
   /** Simulates a crash of OS or machine by overwriting
    *  unsynced files. */
   public synchronized void crash() throws IOException {
-    crashed = true;
     openFiles = new HashMap<>();
     openFilesForWrite = new HashSet<>();
     openFilesDeleted = new HashSet<>();
@@ -303,7 +279,7 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
 
       if (damage == 0) {
         action = "deleted";
-        deleteFile(name, true);
+        deleteFiles(Collections.singleton(name));
       } else if (damage == 1) {
         action = "zeroed";
         // Zero out file entirely
@@ -337,28 +313,45 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
         ii.close();
 
         // Delete original and copy bytes back:
-        deleteFile(name, true);
+        deleteFiles(Collections.singleton(name));
         
-        final IndexOutput out = in.createOutput(name, LuceneTestCase.newIOContext(randomState));
-        ii = in.openInput(tempFileName, LuceneTestCase.newIOContext(randomState));
-        out.copyBytes(ii, ii.length());
-        out.close();
-        ii.close();
-        deleteFile(tempFileName, true);
+        try(IndexOutput out = in.createOutput(name, LuceneTestCase.newIOContext(randomState))) {
+          ii = in.openInput(tempFileName, LuceneTestCase.newIOContext(randomState));
+          out.copyBytes(ii, ii.length());
+          ii.close();
+        } catch (IOException ioe) {
+          // VirusCheckingFS may have blocked the delete, at which point FSDir cannot overwrite here
+          if (ioe.getMessage().equals("file \"" + name + "\" is pending delete and cannot be overwritten")) {
+            // OK
+            action = "deleted";
+          } else {
+            throw ioe;
+          }
+        }
+        deleteFiles(Collections.singleton(tempFileName));
       } else if (damage == 3) {
         // The file survived intact:
         action = "didn't change";
       } else {
         action = "fully truncated";
         // Totally truncate the file to zero bytes
-        deleteFile(name, true);
-        IndexOutput out = in.createOutput(name, LuceneTestCase.newIOContext(randomState));
-        out.close();
+        deleteFiles(Collections.singleton(name));
+        try (IndexOutput out = in.createOutput(name, LuceneTestCase.newIOContext(randomState))) {
+        } catch (IOException ioe) {
+          // VirusCheckingFS may have blocked the delete, at which point FSDir cannot overwrite here
+          if (ioe.getMessage().equals("file \"" + name + "\" is pending delete and cannot be overwritten")) {
+            // OK
+            action = "deleted";
+          } else {
+            throw ioe;
+          }
+        }
       }
       if (LuceneTestCase.VERBOSE) {
         System.out.println("MockDirectoryWrapper: " + action + " unsynced file: " + name);
       }
     }
+    crashed = true;
   }
 
   public synchronized void clearCrash() {
@@ -385,18 +378,6 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
   }
 
   /**
-   * Emulate windows whereby deleting an open file is not
-   * allowed (raise IOException).
-  */
-  public void setNoDeleteOpenFile(boolean value) {
-    this.noDeleteOpenFile = value;
-  }
-  
-  public boolean getNoDeleteOpenFile() {
-    return noDeleteOpenFile;
-  }
-  
-  /**
    * Trip a test assert if there is an attempt
    * to delete an open file.
   */
@@ -468,9 +449,28 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
   }
 
   @Override
-  public synchronized void deleteFile(String name) throws IOException {
+  public synchronized void deleteFiles(Collection<String> names) throws IOException {
     maybeYield();
-    deleteFile(name, false);
+
+    maybeThrowDeterministicException();
+
+    if (crashed) {
+      throw new IOException("cannot delete after crash");
+    }
+
+    for(String name : names) {
+      if (openFiles.containsKey(name)) {
+        openFilesDeleted.add(name);
+        if (assertNoDeleteOpenFile) {
+          throw (IOException) fillOpenTrace(new IOException("MockDirectoryWrapper: file \"" + name + "\" is still open: cannot delete"), name, true);
+        }
+      } else {
+        openFilesDeleted.remove(name);
+      }
+    }
+
+    unSyncedFiles.removeAll(names);
+    in.deleteFiles(names);
   }
 
   // sets the cause of the incoming ioe to be the stack
@@ -494,46 +494,6 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
     }
   }
 
-  private synchronized void deleteFile(String name, boolean forced) throws IOException {
-    maybeYield();
-
-    maybeThrowDeterministicException();
-
-    if (crashed && !forced)
-      throw new IOException("cannot delete after crash");
-
-    if (unSyncedFiles.contains(name))
-      unSyncedFiles.remove(name);
-    if (!forced && (noDeleteOpenFile || assertNoDeleteOpenFile)) {
-      if (openFiles.containsKey(name)) {
-        openFilesDeleted.add(name);
-
-        if (!assertNoDeleteOpenFile) {
-          throw (IOException) fillOpenTrace(new IOException("MockDirectoryWrapper: file \"" + name + "\" is still open: cannot delete"), name, true);
-        } else {
-          throw (AssertionError) fillOpenTrace(new AssertionError("MockDirectoryWrapper: file \"" + name + "\" is still open: cannot delete"), name, true);
-        }
-      } else {
-        openFilesDeleted.remove(name);
-      }
-    }
-    if (!forced && enableVirusScanner && (randomState.nextInt(4) == 0)) {
-      triedToDelete.add(name);
-      if (LuceneTestCase.VERBOSE) {
-        System.out.println("MDW: now refuse to delete file: " + name);
-      }
-      throw new IOException("cannot delete file: " + name + ", a virus scanner has it open");
-    }
-    triedToDelete.remove(name);
-    in.deleteFile(name);
-  }
-
-  /** Returns true if {@link #deleteFile} was called with this
-   *  fileName, but the virus checker prevented the deletion. */
-  public boolean didTryToDelete(String fileName) {
-    return triedToDelete.contains(fileName);
-  }
-
   public synchronized Set<String> getOpenDeletedFiles() {
     return new HashSet<>(openFilesDeleted);
   }
@@ -561,12 +521,8 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
         throw new IOException("file \"" + name + "\" was already written to");
       }
     }
-    if ((noDeleteOpenFile || assertNoDeleteOpenFile) && openFiles.containsKey(name)) {
-      if (!assertNoDeleteOpenFile) {
-        throw new IOException("MockDirectoryWrapper: file \"" + name + "\" is still open: cannot overwrite");
-      } else {
-        throw new AssertionError("MockDirectoryWrapper: file \"" + name + "\" is still open: cannot overwrite");
-      }
+    if (assertNoDeleteOpenFile && openFiles.containsKey(name)) {
+      throw new AssertionError("MockDirectoryWrapper: file \"" + name + "\" is still open: cannot overwrite");
     }
     
     unSyncedFiles.add(name);
@@ -751,9 +707,6 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
       // files that we tried to delete, but couldn't because readers were open.
       // all that matters is that we tried! (they will eventually go away)
       //   still open when we tried to delete
-      Set<String> pendingDeletions = new HashSet<>(openFilesDeleted);
-      //   virus scanner when we tried to delete
-      pendingDeletions.addAll(triedToDelete);
       maybeYield();
       if (openFiles == null) {
         openFiles = new HashMap<>();
@@ -782,6 +735,7 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
       if (getCheckIndexOnClose()) {
         randomIOExceptionRate = 0.0;
         randomIOExceptionRateOnOpen = 0.0;
+
         if (DirectoryReader.indexExists(this)) {
           if (LuceneTestCase.VERBOSE) {
             System.out.println("\nNOTE: MockDirectoryWrapper: now crush");
@@ -790,13 +744,14 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
           if (LuceneTestCase.VERBOSE) {
             System.out.println("\nNOTE: MockDirectoryWrapper: now run CheckIndex");
           } 
+
+          // nocommit: we should also confirm all prior segments_N are not corrupt?
           TestUtil.checkIndex(this, getCrossCheckTermVectorsOnClose(), true);
           
           // TODO: factor this out / share w/ TestIW.assertNoUnreferencedFiles
           if (assertNoUnreferencedFilesOnClose) {
             // now look for unreferenced files: discount ones that we tried to delete but could not
             Set<String> allFiles = new HashSet<>(Arrays.asList(listAll()));
-            allFiles.removeAll(pendingDeletions);
             String[] startFiles = allFiles.toArray(new String[0]);
             IndexWriterConfig iwc = new IndexWriterConfig(null);
             iwc.setIndexDeletionPolicy(NoDeletionPolicy.INSTANCE);
@@ -806,51 +761,6 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
             Set<String> startSet = new TreeSet<>(Arrays.asList(startFiles));
             Set<String> endSet = new TreeSet<>(Arrays.asList(endFiles));
             
-            if (pendingDeletions.contains("segments.gen") && endSet.contains("segments.gen")) {
-              // this is possible if we hit an exception while writing segments.gen, we try to delete it
-              // and it ends out in pendingDeletions (but IFD wont remove this).
-              startSet.add("segments.gen");
-              if (LuceneTestCase.VERBOSE) {
-                System.out.println("MDW: Unreferenced check: Ignoring segments.gen that we could not delete.");
-              }
-            }
-            
-            // it's possible we cannot delete the segments_N on windows if someone has it open and
-            // maybe other files too, depending on timing. normally someone on windows wouldnt have
-            // an issue (IFD would nuke this stuff eventually), but we pass NoDeletionPolicy...
-            for (String file : pendingDeletions) {
-              if (file.startsWith("segments") && !file.equals("segments.gen") && endSet.contains(file)) {
-                startSet.add(file);
-                if (LuceneTestCase.VERBOSE) {
-                  System.out.println("MDW: Unreferenced check: Ignoring segments file: " + file + " that we could not delete.");
-                }
-                SegmentInfos sis;
-                try {
-                  sis = SegmentInfos.readCommit(in, file);
-                } catch (IOException ioe) {
-                  // OK: likely some of the .si files were deleted
-                  sis = new SegmentInfos();
-                }
-                
-                try {
-                  Set<String> ghosts = new HashSet<>(sis.files(false));
-                  for (String s : ghosts) {
-                    if (endSet.contains(s) && !startSet.contains(s)) {
-                      assert pendingDeletions.contains(s);
-                      if (LuceneTestCase.VERBOSE) {
-                        System.out.println("MDW: Unreferenced check: Ignoring referenced file: " + s + " " +
-                            "from " + file + " that we could not delete.");
-                      }
-                      startSet.add(s);
-                    }
-                  }
-                } catch (Throwable t) {
-                  System.err.println("ERROR processing leftover segments file " + file + ":");
-                  t.printStackTrace();
-                }
-              }
-            }
-            
             startFiles = startSet.toArray(new String[0]);
             endFiles = endSet.toArray(new String[0]);
             
@@ -880,10 +790,6 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
                 extras += "\n\nThese files were added (waaaaaaaaaat!): " + added;
               }
               
-              if (pendingDeletions.size() != 0) {
-                extras += "\n\nThese files we had previously tried to delete, but couldn't: " + pendingDeletions;
-              }
-              
               throw new RuntimeException("unreferenced files: before delete:\n    " + Arrays.toString(startFiles) + "\n  after delete:\n    " + Arrays.toString(endFiles) + extras);
             }
             

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleTemporaryFilesCleanup.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleTemporaryFilesCleanup.java b/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleTemporaryFilesCleanup.java
index 86f685a..27e4fb9 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleTemporaryFilesCleanup.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleTemporaryFilesCleanup.java
@@ -39,6 +39,7 @@ import org.apache.lucene.mockfile.HandleLimitFS;
 import org.apache.lucene.mockfile.LeakFS;
 import org.apache.lucene.mockfile.ShuffleFS;
 import org.apache.lucene.mockfile.VerboseFS;
+import org.apache.lucene.mockfile.VirusCheckingFS;
 import org.apache.lucene.mockfile.WindowsFS;
 import org.apache.lucene.util.LuceneTestCase.SuppressFileSystems;
 import org.apache.lucene.util.LuceneTestCase.SuppressFsync;
@@ -75,6 +76,11 @@ final class TestRuleTemporaryFilesCleanup extends TestRuleAdapter {
   private FileSystem fileSystem;
 
   /**
+   * Only set if the file system chain includes the VirusCheckingFS
+   */
+  private VirusCheckingFS virusCheckingFS;
+
+  /**
    * Suite failure marker.
    */
   private final TestRuleMarkFailure failureMarker;
@@ -174,10 +180,17 @@ final class TestRuleTemporaryFilesCleanup extends TestRuleAdapter {
       if (allowed(avoid, ExtrasFS.class)) {
         fs = new ExtrasFS(fs, random.nextInt(4) == 0, random.nextBoolean()).getFileSystem(null);
       }
+      // nocommit true:
+      if (allowed(avoid, VirusCheckingFS.class) && (true || random.nextInt(10) == 1)) {
+        // 10% of the time we swap in virus checking (acts-like-windows) FS:    
+        virusCheckingFS = new VirusCheckingFS(fs, random);
+        fs = virusCheckingFS.getFileSystem(null);
+      }
     }
     if (LuceneTestCase.VERBOSE) {
       System.out.println("filesystem: " + fs.provider());
     }
+
     return fs.provider().getFileSystem(URI.create("file:///"));
   }
 
@@ -211,6 +224,12 @@ final class TestRuleTemporaryFilesCleanup extends TestRuleAdapter {
     // was successful. Otherwise just report the path of temporary files
     // and leave them there.
     if (failureMarker.wasSuccessful()) {
+
+      if (virusCheckingFS != null) {
+        // Otherwise our IOUtils.rm below can fail:
+        virusCheckingFS.disable();
+      }
+
       try {
         IOUtils.rm(everything);
       } catch (IOException e) {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java b/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java
index 99d4be3..89af2e2 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java
@@ -26,6 +26,7 @@ import java.io.PrintStream;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.nio.CharBuffer;
+import java.nio.file.FileSystem;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.ArrayList;
@@ -90,10 +91,15 @@ import org.apache.lucene.index.SlowCodecReaderWrapper;
 import org.apache.lucene.index.Terms;
 import org.apache.lucene.index.TermsEnum;
 import org.apache.lucene.index.TieredMergePolicy;
+import org.apache.lucene.mockfile.FilterFileSystem;
+import org.apache.lucene.mockfile.VirusCheckingFS;
+import org.apache.lucene.mockfile.WindowsFS;
 import org.apache.lucene.search.FieldDoc;
 import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.FSDirectory;
+import org.apache.lucene.store.FilterDirectory;
 import org.apache.lucene.store.IOContext;
 import org.apache.lucene.store.NoLockFactory;
 import org.apache.lucene.store.RAMDirectory;
@@ -102,6 +108,7 @@ import org.junit.Assert;
 import com.carrotsearch.randomizedtesting.generators.RandomInts;
 import com.carrotsearch.randomizedtesting.generators.RandomPicks;
 
+
 /**
  * General utility methods for Lucene unit tests. 
  */
@@ -1281,4 +1288,43 @@ public final class TestUtil {
     }
     return ram;
   }
+
+  public static boolean hasWindowsFS(Directory dir) {
+    dir = FilterDirectory.unwrap(dir);
+    if (dir instanceof FSDirectory) {
+      Path path = ((FSDirectory) dir).getDirectory();
+      FileSystem fs = path.getFileSystem();
+      while (fs instanceof FilterFileSystem) {
+        FilterFileSystem ffs = (FilterFileSystem) fs;
+        if (ffs.getParent() instanceof WindowsFS) {
+          return true;
+        }
+        fs = ffs.getDelegate();
+      }
+    }
+
+    return false;
+  }
+
+  public static boolean hasVirusChecker(Directory dir) {
+    dir = FilterDirectory.unwrap(dir);
+    if (dir instanceof FSDirectory) {
+      return hasVirusChecker(((FSDirectory) dir).getDirectory());
+    } else {
+      return false;
+    }
+  }
+
+  public static boolean hasVirusChecker(Path path) {
+    FileSystem fs = path.getFileSystem();
+    while (fs instanceof FilterFileSystem) {
+      FilterFileSystem ffs = (FilterFileSystem) fs;
+      if (ffs.getParent() instanceof VirusCheckingFS) {
+        return true;
+      }
+      fs = ffs.getDelegate();
+    }
+
+    return false;
+  }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/test-framework/src/java/org/apache/lucene/util/fst/FSTTester.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/fst/FSTTester.java b/lucene/test-framework/src/java/org/apache/lucene/util/fst/FSTTester.java
index a2ace61..3800ff7 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/util/fst/FSTTester.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/util/fst/FSTTester.java
@@ -317,7 +317,7 @@ public class FSTTester<T> {
         fst = new FST<>(in, outputs);
       } finally {
         in.close();
-        dir.deleteFile("fst.bin");
+        dir.deleteFiles(Collections.singleton("fst.bin"));
       }
     }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/test-framework/src/test/org/apache/lucene/codecs/compressing/TestCompressingStoredFieldsFormat.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/test/org/apache/lucene/codecs/compressing/TestCompressingStoredFieldsFormat.java b/lucene/test-framework/src/test/org/apache/lucene/codecs/compressing/TestCompressingStoredFieldsFormat.java
index d416f8a..f69ea19 100644
--- a/lucene/test-framework/src/test/org/apache/lucene/codecs/compressing/TestCompressingStoredFieldsFormat.java
+++ b/lucene/test-framework/src/test/org/apache/lucene/codecs/compressing/TestCompressingStoredFieldsFormat.java
@@ -55,10 +55,6 @@ public class TestCompressingStoredFieldsFormat extends BaseStoredFieldsFormatTes
 
   public void testDeletePartiallyWrittenFilesIfAbort() throws IOException {
     Directory dir = newDirectory();
-    // test explicitly needs files to always be actually deleted
-    if (dir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper)dir).setEnableVirusScanner(false);
-    }
     IndexWriterConfig iwConf = newIndexWriterConfig(new MockAnalyzer(random()));
     iwConf.setMaxBufferedDocs(RandomInts.randomIntBetween(random(), 2, 30));
     iwConf.setCodec(CompressingCodec.randomInstance(random()));

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/test-framework/src/test/org/apache/lucene/mockfile/TestVirusCheckingFS.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/test/org/apache/lucene/mockfile/TestVirusCheckingFS.java b/lucene/test-framework/src/test/org/apache/lucene/mockfile/TestVirusCheckingFS.java
new file mode 100644
index 0000000..17b1575
--- /dev/null
+++ b/lucene/test-framework/src/test/org/apache/lucene/mockfile/TestVirusCheckingFS.java
@@ -0,0 +1,62 @@
+package org.apache.lucene.mockfile;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URI;
+import java.nio.file.AccessDeniedException;
+import java.nio.file.FileSystem;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+/** Basic tests for VirusCheckingFS */
+public class TestVirusCheckingFS extends MockFileSystemTestCase {
+  
+  @Override
+  protected Path wrap(Path path) {
+    FileSystem fs = new VirusCheckingFS(path.getFileSystem(), random()).getFileSystem(URI.create("file:///"));
+    return new FilterPath(path, fs);
+  }
+  
+  /** Test Files.delete fails if a file has an open inputstream against it */
+  public void testDeleteSometimesFails() throws IOException {
+    Path dir = wrap(createTempDir());
+
+    int counter = 0;
+    while (true) {
+      Path path = dir.resolve("file" + counter);
+      counter++;
+
+      OutputStream file = Files.newOutputStream(path);
+      file.write(5);
+      file.close();
+
+      // File is now closed, we attempt delete:
+      try {
+        Files.delete(path);
+      } catch (AccessDeniedException ade) {
+        // expected (sometimes)
+        assertTrue(ade.getMessage().contains("VirusCheckingFS is randomly refusing to delete file "));
+        break;
+      }
+
+      assertFalse(Files.exists(path));
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/test-framework/src/test/org/apache/lucene/mockfile/TestWindowsFS.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/test/org/apache/lucene/mockfile/TestWindowsFS.java b/lucene/test-framework/src/test/org/apache/lucene/mockfile/TestWindowsFS.java
index 333ff00..7b80604 100644
--- a/lucene/test-framework/src/test/org/apache/lucene/mockfile/TestWindowsFS.java
+++ b/lucene/test-framework/src/test/org/apache/lucene/mockfile/TestWindowsFS.java
@@ -41,10 +41,10 @@ import org.apache.lucene.util.Constants;
 /** Basic tests for WindowsFS */
 public class TestWindowsFS extends MockFileSystemTestCase {
   
-  // currently we don't emulate windows well enough to work on windows!
   @Override
   public void setUp() throws Exception {
     super.setUp();
+    // irony: currently we don't emulate windows well enough to work on windows!
     assumeFalse("windows is not supported", Constants.WINDOWS);
   }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/lucene/test-framework/src/test/org/apache/lucene/store/TestMockDirectoryWrapper.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/test/org/apache/lucene/store/TestMockDirectoryWrapper.java b/lucene/test-framework/src/test/org/apache/lucene/store/TestMockDirectoryWrapper.java
index fd30582..92bf568 100644
--- a/lucene/test-framework/src/test/org/apache/lucene/store/TestMockDirectoryWrapper.java
+++ b/lucene/test-framework/src/test/org/apache/lucene/store/TestMockDirectoryWrapper.java
@@ -37,7 +37,6 @@ public class TestMockDirectoryWrapper extends BaseDirectoryTestCase {
     } else {
       dir = newMockFSDirectory(path);
     }
-    dir.setEnableVirusScanner(false); // test manipulates filesystem directly
     return dir;
   }
   

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java b/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java
index 715b6a6..cf7220d 100644
--- a/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java
+++ b/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java
@@ -22,6 +22,7 @@ import java.io.File;
 import java.io.FileFilter;
 import java.io.IOException;
 import java.lang.invoke.MethodHandles;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 
@@ -155,7 +156,7 @@ public abstract class DirectoryFactory implements NamedListInitializedPlugin,
    */
   public void move(Directory fromDir, Directory toDir, String fileName, IOContext ioContext) throws IOException {
     toDir.copyFrom(fromDir, fileName, fileName, ioContext);
-    fromDir.deleteFile(fileName);
+    fromDir.deleteFiles(Collections.singleton(fileName));
   }
   
   /**
@@ -248,9 +249,7 @@ public abstract class DirectoryFactory implements NamedListInitializedPlugin,
     try {
       contents = dir.listAll();
       if (contents != null) {
-        for (String file : contents) {
-          dir.deleteFile(file);
-        }
+        dir.deleteFiles(Arrays.asList(contents));
       }
     } catch (IOException e) {
       SolrException.log(log, "Error deleting files from Directory", e);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
index 862d4e7..86aaf95 100644
--- a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
+++ b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
@@ -1206,7 +1206,7 @@ public class IndexFetcher {
         }
       }
       try {
-        dir.deleteFile(IndexFetcher.INDEX_PROPERTIES);
+        dir.deleteFiles(Collections.singleton(IndexFetcher.INDEX_PROPERTIES));
       } catch (IOException e) {
         // no problem
       }
@@ -1651,7 +1651,7 @@ public class IndexFetcher {
     }
 
     public void delete() throws Exception {
-      copy2Dir.deleteFile(saveAs);
+      copy2Dir.deleteFiles(Collections.singleton(saveAs));
     }
   }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f44589/solr/core/src/java/org/apache/solr/handler/RestoreCore.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/RestoreCore.java b/solr/core/src/java/org/apache/solr/handler/RestoreCore.java
index d6a7e1d..cf426ce 100644
--- a/solr/core/src/java/org/apache/solr/handler/RestoreCore.java
+++ b/solr/core/src/java/org/apache/solr/handler/RestoreCore.java
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.lang.invoke.MethodHandles;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.Collections;
 import java.util.concurrent.Callable;
 import java.util.concurrent.Future;
 
@@ -111,7 +112,7 @@ public class RestoreCore implements Callable<Boolean> {
         try {
           dir = core.getDirectoryFactory().get(core.getDataDir(), DirectoryFactory.DirContext.META_DATA,
               core.getSolrConfig().indexConfig.lockType);
-          dir.deleteFile(IndexFetcher.INDEX_PROPERTIES);
+          dir.deleteFiles(Collections.singleton(IndexFetcher.INDEX_PROPERTIES));
         } finally {
           if (dir != null) {
             core.getDirectoryFactory().release(dir);