Workaround for JDK 14 EA FileChannel.map issue (#50523)
FileChannel.map provokes static initialization of ExtendedMapMode in JDK14 EA, which needs elevated privileges. Relates #50512
This commit is contained in:
parent
9ae3cd2a78
commit
312bf44601
|
@ -160,6 +160,24 @@ final class Bootstrap {
|
|||
JvmInfo.jvmInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* JDK 14 bug:
|
||||
* https://github.com/elastic/elasticsearch/issues/50512
|
||||
* We circumvent it here by loading the offending class before installing security manager.
|
||||
*
|
||||
* To be removed once the JDK is fixed.
|
||||
*/
|
||||
static void fixJDK14EAFileChannelMap() {
|
||||
// minor time-bomb here to ensure that we reevaluate if final 14 version does not include fix.
|
||||
if (System.getProperty("java.version").equals("14-ea")) {
|
||||
try {
|
||||
Class.forName("jdk.internal.misc.ExtendedMapMode", true, Bootstrap.class.getClassLoader());
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException("Unable to lookup ExtendedMapMode class", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setup(boolean addShutdownHook, Environment environment) throws BootstrapException {
|
||||
Settings settings = environment.settings();
|
||||
|
||||
|
@ -211,6 +229,8 @@ final class Bootstrap {
|
|||
// Log ifconfig output before SecurityManager is installed
|
||||
IfConfig.logIfNecessary();
|
||||
|
||||
fixJDK14EAFileChannelMap();
|
||||
|
||||
// install SM after natives, shutdown hooks, etc.
|
||||
try {
|
||||
Security.configure(environment, BootstrapSettings.SECURITY_FILTER_BAD_DEFAULTS_SETTING.get(settings));
|
||||
|
|
|
@ -102,6 +102,8 @@ public class BootstrapForTesting {
|
|||
// Log ifconfig output before SecurityManager is installed
|
||||
IfConfig.logIfNecessary();
|
||||
|
||||
Bootstrap.fixJDK14EAFileChannelMap();
|
||||
|
||||
// install security manager if requested
|
||||
if (systemPropertyAsBoolean("tests.security.manager", true)) {
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue