mirror of https://github.com/apache/lucene.git
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
This commit is contained in:
parent
2a7687641e
commit
53597e8f8e
|
@ -78,6 +78,7 @@ import org.apache.lucene.store.IOContext;
|
||||||
import org.apache.lucene.store.IndexInput;
|
import org.apache.lucene.store.IndexInput;
|
||||||
import org.apache.lucene.store.IndexOutput;
|
import org.apache.lucene.store.IndexOutput;
|
||||||
import org.apache.lucene.store.LockObtainFailedException;
|
import org.apache.lucene.store.LockObtainFailedException;
|
||||||
|
import org.apache.lucene.store.MMapDirectory;
|
||||||
import org.apache.lucene.store.MockDirectoryWrapper;
|
import org.apache.lucene.store.MockDirectoryWrapper;
|
||||||
import org.apache.lucene.store.NIOFSDirectory;
|
import org.apache.lucene.store.NIOFSDirectory;
|
||||||
import org.apache.lucene.store.NoLockFactory;
|
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:///"));
|
FileSystem fs = new WindowsFS(path.getFileSystem()).getFileSystem(URI.create("file:///"));
|
||||||
Path indexPath = new FilterPath(path, fs);
|
Path indexPath = new FilterPath(path, fs);
|
||||||
|
|
||||||
// NOTE: cannot use MMapDir, because WindowsFS doesn't see/think it keeps file handles open?
|
// NOTE: on Unix, we cannot use MMapDir, because WindowsFS doesn't see/think it keeps file handles open. Yet, on Windows, we MUST use
|
||||||
FSDirectory dir = new NIOFSDirectory(indexPath);
|
// 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);
|
MergePolicy mergePolicy = newLogMergePolicy(true);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue