Index: lucene/src/java/org/apache/lucene/store/MMapDirectory.java
===================================================================
--- lucene/src/java/org/apache/lucene/store/MMapDirectory.java (revision 998311)
+++ lucene/src/java/org/apache/lucene/store/MMapDirectory.java (working copy)
@@ -78,7 +78,7 @@
*
*/
public class MMapDirectory extends FSDirectory {
- private boolean useUnmapHack = false;
+ private boolean useUnmapHack = UNMAP_SUPPORTED;
private int maxBBuf = Constants.JRE_IS_64BIT ? Integer.MAX_VALUE : (256 * 1024 * 1024);
/** Create a new MMapDirectory for the named location.
@@ -100,22 +100,89 @@
public MMapDirectory(File path) throws IOException {
super(path, null);
}
+
+ private enum Platform {
+ UNSUPPORTED {
+ @Override
+ final void cleanMapping(final ByteBuffer buffer) {
+ // do nothing
+ }
+ },
+
+ SUN {
+ @Override
+ final void cleanMapping(final ByteBuffer buffer) throws IOException {
+ try {
+ AccessController.doPrivileged(new PrivilegedExceptionAction