Skip to content

Apache Lucene open-source search software

LUCENE-2825: Change FSDirectory.open to return MMap on 64-bit Solaris

Robert Muir25b3f63fbd5f
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 17852b48009..d93f2723b26 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -121,8 +121,8 @@ Changes in backwards compatibility policy
Changes in Runtime Behavior
-* LUCENE-2650: The behavior of FSDirectory.open has changed. On 64-bit
- Windows systems that support unmapping, FSDirectory.open returns
+* LUCENE-2650, LUCENE-2825: The behavior of FSDirectory.open has changed. On 64-bit
+ Windows and Solaris systems that support unmapping, FSDirectory.open returns
MMapDirectory. Additionally the behavior of MMapDirectory has been
changed to enable unmapping by default if supported by the JRE.
(Mike McCandless, Uwe Schindler, Robert Muir)
diff --git a/lucene/src/java/org/apache/lucene/store/FSDirectory.java b/lucene/src/java/org/apache/lucene/store/FSDirectory.java
index d2eb3b6c7e6..fcb79138fb5 100644
--- a/lucene/src/java/org/apache/lucene/store/FSDirectory.java
+++ b/lucene/src/java/org/apache/lucene/store/FSDirectory.java
@@ -161,10 +161,10 @@ public abstract class FSDirectory extends Directory {
* best implementation given the current environment.
* The directory returned uses the {@link NativeFSLockFactory}.
*
- * <p>Currently this returns {@link NIOFSDirectory}
- * 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
+ * <p>Currently this returns {@link MMapDirectory} for most Solaris
+ * and Windows 64-bit JREs, {@link NIOFSDirectory} for other
+ * non-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.
*
@@ -184,11 +184,11 @@ public abstract class FSDirectory extends Directory {
/** Just like {@link #open(File)}, but allows you to
* also specify a custom {@link LockFactory}. */
public static FSDirectory open(File path, LockFactory lockFactory) throws IOException {
- if (Constants.WINDOWS) {
- if (MMapDirectory.UNMAP_SUPPORTED && Constants.JRE_IS_64BIT)
- return new MMapDirectory(path, lockFactory);
- else
- return new SimpleFSDirectory(path, lockFactory);
+ if ((Constants.WINDOWS || Constants.SUN_OS)
+ && Constants.JRE_IS_64BIT && MMapDirectory.UNMAP_SUPPORTED) {
+ return new MMapDirectory(path, lockFactory);
+ } else if (Constants.WINDOWS) {
+ return new SimpleFSDirectory(path, lockFactory);
} else {
return new NIOFSDirectory(path, lockFactory);
}