Skip to content

Commit b44aac7

Browse files
committed
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.
1 parent 5d001d1 commit b44aac7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

core/src/test/java/org/elasticsearch/common/lucene/LuceneTests.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.lucene.search.MatchAllDocsQuery;
2929
import org.apache.lucene.search.TermQuery;
3030
import org.apache.lucene.store.Directory;
31+
import org.apache.lucene.store.MMapDirectory;
3132
import org.apache.lucene.store.MockDirectoryWrapper;
3233
import org.apache.lucene.util.Version;
3334
import org.elasticsearch.test.ESTestCase;
@@ -359,4 +360,15 @@ public void testCount() throws Exception {
359360
w.close();
360361
dir.close();
361362
}
363+
364+
/**
365+
* Test that the "unmap hack" is detected as supported by lucene.
366+
* <p>
367+
* While not guaranteed, current status is "Critical Internal API": http://openjdk.java.net/jeps/260
368+
* Additionally this checks we did not screw up the security logic around the hack.
369+
*/
370+
public void testMMapHackSupported() throws Exception {
371+
// add assume's here if needed for certain platforms, but we should know if it does not work.
372+
assertTrue(MMapDirectory.UNMAP_SUPPORTED);
373+
}
362374
}

0 commit comments

Comments
 (0)