Index: lucene/src/test/org/apache/lucene/util/LuceneTestCase.java =================================================================== --- lucene/src/test/org/apache/lucene/util/LuceneTestCase.java (revision 998212) +++ lucene/src/test/org/apache/lucene/util/LuceneTestCase.java (working copy) @@ -716,11 +716,7 @@ tmpFile.mkdir(); try { Constructor extends Directory> ctor = clazz.getConstructor(File.class); - Directory d = ctor.newInstance(tmpFile); - // try not to enable this hack unless we must. - if (d instanceof MMapDirectory && Constants.WINDOWS && MMapDirectory.UNMAP_SUPPORTED) - ((MMapDirectory)d).setUseUnmap(true); - return d; + return ctor.newInstance(tmpFile); } catch (Exception e2) { // try .open(File) Method method = clazz.getMethod("open", new Class[] { File.class }); Index: lucene/src/java/org/apache/lucene/store/MMapDirectory.java =================================================================== --- lucene/src/java/org/apache/lucene/store/MMapDirectory.java (revision 998212) +++ lucene/src/java/org/apache/lucene/store/MMapDirectory.java (working copy) @@ -64,7 +64,7 @@ * an important limitation to be aware of. * *
This class supplies the workaround mentioned in the bug report
- * (disabled by default, see {@link #setUseUnmap}), which may fail on
+ * (see {@link #setUseUnmap}), which may fail on
* non-Sun JVMs. It forcefully unmaps the buffer on close by using
* an undocumented internal cleanup functionality.
* {@link #UNMAP_SUPPORTED} is true, if the workaround
@@ -78,7 +78,7 @@
*
Currently this returns {@link NIOFSDirectory} - * on non-Windows JREs and {@link SimpleFSDirectory} - * on Windows. It is highly recommended that you consult the + * on non-Windows JREs, {@link MMapDirectory} on 64-bit + * Sun Windows JREs, and {@link SimpleFSDirectory} for other + * JRes on Windows. It is highly recommended that you consult the * implementation's documentation for your platform before * using this method. * @@ -193,11 +194,8 @@ * the event that higher performance defaults become * possible; if the precise implementation is important to * your application, please instantiate it directly, - * instead. On 64 bit systems, it may also good to - * return {@link MMapDirectory}, but this is disabled - * because of officially missing unmap support in Java. - * For optimal performance you should consider using - * this implementation on 64 bit JVMs. + * instead. For optimal performance you should consider using + * {@link MMapDirectory} on 64 bit JVMs. * *
See above */ public static FSDirectory open(File path) throws IOException { @@ -208,7 +206,10 @@ * also specify a custom {@link LockFactory}. */ public static FSDirectory open(File path, LockFactory lockFactory) throws IOException { if (Constants.WINDOWS) { - return new SimpleFSDirectory(path, lockFactory); + if (MMapDirectory.UNMAP_SUPPORTED && Constants.JRE_IS_64BIT) + return new MMapDirectory(path, lockFactory); + else + return new SimpleFSDirectory(path, lockFactory); } else { return new NIOFSDirectory(path, lockFactory); }