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/07 20:45:51 UTC

[14/21] lucene-solr git commit: try to fix test bug, so that on Windows instead of relying on WindowsFS to prevent deletion of open files, we rely on the OS itself

try to fix test bug, so that on Windows instead of relying on WindowsFS to prevent deletion of open files, we rely on the OS itself


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

Branch: refs/heads/jira/lucene-5438-nrt-replication
Commit: 53597e8f8e3fe97ce06cfcb98ab313ee7c9ae45f
Parents: 2a76876
Author: Mike McCandless <mi...@apache.org>
Authored: Sun Feb 7 07:04:10 2016 -0500
Committer: Mike McCandless <mi...@apache.org>
Committed: Sun Feb 7 07:04:10 2016 -0500

----------------------------------------------------------------------
 .../test/org/apache/lucene/index/TestIndexWriter.java    | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/53597e8f/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
index 4f6ef89..b9dd899 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
@@ -78,6 +78,7 @@ import org.apache.lucene.store.IOContext;
 import org.apache.lucene.store.IndexInput;
 import org.apache.lucene.store.IndexOutput;
 import org.apache.lucene.store.LockObtainFailedException;
+import org.apache.lucene.store.MMapDirectory;
 import org.apache.lucene.store.MockDirectoryWrapper;
 import org.apache.lucene.store.NIOFSDirectory;
 import org.apache.lucene.store.NoLockFactory;
@@ -1268,8 +1269,14 @@ public class TestIndexWriter extends LuceneTestCase {
       FileSystem fs = new WindowsFS(path.getFileSystem()).getFileSystem(URI.create("file:///"));
       Path indexPath = new FilterPath(path, fs);
 
-      // NOTE: cannot use MMapDir, because WindowsFS doesn't see/think it keeps file handles open?
-      FSDirectory dir = new NIOFSDirectory(indexPath);
+      // NOTE: on Unix, we cannot use MMapDir, because WindowsFS doesn't see/think it keeps file handles open.  Yet, on Windows, we MUST use
+      // MMapDir because the windows OS will in fact prevent file deletion for us, and fails otherwise:
+      FSDirectory dir;
+      if (Constants.WINDOWS) {
+        dir = new MMapDirectory(indexPath);
+      } else {
+        dir = new NIOFSDirectory(indexPath);
+      }
 
       MergePolicy mergePolicy = newLogMergePolicy(true);