You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2015/02/25 23:21:20 UTC
svn commit: r1662318 - in /lucene/dev/branches/branch_5x: ./ lucene/
lucene/core/ lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java
Author: uschindler
Date: Wed Feb 25 22:21:19 2015
New Revision: 1662318
URL: http://svn.apache.org/r1662318
Log:
Merged revision(s) 1662317 from lucene/dev/trunk:
LUCENE-6238: Remove access to sun.misc package from static <clinit> code.
Modified:
lucene/dev/branches/branch_5x/ (props changed)
lucene/dev/branches/branch_5x/lucene/ (props changed)
lucene/dev/branches/branch_5x/lucene/core/ (props changed)
lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java
Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java?rev=1662318&r1=1662317&r2=1662318&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java Wed Feb 25 22:21:19 2015
@@ -25,6 +25,7 @@ import java.nio.channels.FileChannel.Map
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.security.PrivilegedExceptionAction;
import java.security.PrivilegedActionException;
import java.util.Locale;
@@ -158,19 +159,17 @@ public class MMapDirectory extends FSDir
/**
* <code>true</code>, if this platform supports unmapping mmapped files.
*/
- public static final boolean UNMAP_SUPPORTED;
- static {
- boolean v;
- try {
- Class.forName("sun.misc.Cleaner");
- Class.forName("java.nio.DirectByteBuffer")
- .getMethod("cleaner");
- v = true;
- } catch (Exception e) {
- v = false;
+ public static final boolean UNMAP_SUPPORTED = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+ @Override
+ public Boolean run() {
+ try {
+ Class.forName("java.nio.DirectByteBuffer").getMethod("cleaner");
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
}
- UNMAP_SUPPORTED = v;
- }
+ });
/**
* This method enables the workaround for unmapping the buffers