浏览代码

Test that the lucene "unmap hack" is supported.

Closes #14120

Squashed commit of the following:

commit 556b7f5783211bd82a5d9796996e21be87b0404b
Author: Robert Muir <rmuir@apache.org>
Date:   Wed Oct 14 15:16:54 2015 -0400

    Add bugid link

commit b44aac7e9f1a97974938c17e013812ebf4c2fa76
Author: Robert Muir <rmuir@apache.org>
Date:   Wed Oct 14 15:01:41 2015 -0400

    Test that the lucene "unmap hack" is supported.

    We should know if this is not working for any configuration, otherwise resources such as address space, file handles, and even disk space become tied to Java's garbage collector.
Robert Muir 10 年之前
父节点
当前提交
c3751801c6
共有 1 个文件被更改,包括 13 次插入0 次删除
  1. 13 0
      core/src/test/java/org/elasticsearch/common/lucene/LuceneTests.java

+ 13 - 0
core/src/test/java/org/elasticsearch/common/lucene/LuceneTests.java

@@ -28,6 +28,7 @@ import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.MatchAllDocsQuery;
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.MMapDirectory;
 import org.apache.lucene.store.MockDirectoryWrapper;
 import org.apache.lucene.util.Version;
 import org.elasticsearch.test.ESTestCase;
@@ -359,4 +360,16 @@ public class LuceneTests extends ESTestCase {
         w.close();
         dir.close();
     }
+
+    /**
+     * Test that the "unmap hack" is detected as supported by lucene.
+     * This works around the following bug: https://bugs.openjdk.java.net/browse/JDK-4724038
+     * <p>
+     * While not guaranteed, current status is "Critical Internal API": http://openjdk.java.net/jeps/260
+     * Additionally this checks we did not screw up the security logic around the hack.
+     */
+    public void testMMapHackSupported() throws Exception {
+        // add assume's here if needed for certain platforms, but we should know if it does not work.
+        assertTrue(MMapDirectory.UNMAP_SUPPORTED);
+    }
 }