|
19 | 19 |
|
20 | 20 | package org.elasticsearch.bootstrap;
|
21 | 21 |
|
22 |
| -import org.apache.logging.log4j.Logger; |
23 | 22 | import org.apache.logging.log4j.LogManager;
|
| 23 | +import org.apache.logging.log4j.Logger; |
24 | 24 | import org.apache.logging.log4j.core.Appender;
|
25 | 25 | import org.apache.logging.log4j.core.LoggerContext;
|
26 | 26 | import org.apache.logging.log4j.core.appender.ConsoleAppender;
|
27 | 27 | import org.apache.logging.log4j.core.config.Configurator;
|
28 | 28 | import org.apache.lucene.util.Constants;
|
29 |
| -import org.elasticsearch.core.internal.io.IOUtils; |
30 | 29 | import org.apache.lucene.util.StringHelper;
|
31 | 30 | import org.elasticsearch.ElasticsearchException;
|
32 | 31 | import org.elasticsearch.Version;
|
|
41 | 40 | import org.elasticsearch.common.settings.SecureSettings;
|
42 | 41 | import org.elasticsearch.common.settings.Settings;
|
43 | 42 | import org.elasticsearch.common.transport.BoundTransportAddress;
|
| 43 | +import org.elasticsearch.core.internal.io.IOUtils; |
44 | 44 | import org.elasticsearch.env.Environment;
|
45 | 45 | import org.elasticsearch.monitor.jvm.JvmInfo;
|
46 | 46 | import org.elasticsearch.monitor.os.OsProbe;
|
@@ -158,6 +158,24 @@ static void initializeProbes() {
|
158 | 158 | JvmInfo.jvmInfo();
|
159 | 159 | }
|
160 | 160 |
|
| 161 | + /** |
| 162 | + * JDK 14 bug: |
| 163 | + * https://github.com/elastic/elasticsearch/issues/50512 |
| 164 | + * We circumvent it here by loading the offending class before installing security manager. |
| 165 | + * |
| 166 | + * To be removed once the JDK is fixed. |
| 167 | + */ |
| 168 | + static void fixJDK14EAFileChannelMap() { |
| 169 | + // minor time-bomb here to ensure that we reevaluate if final 14 version does not include fix. |
| 170 | + if (System.getProperty("java.version").equals("14-ea")) { |
| 171 | + try { |
| 172 | + Class.forName("jdk.internal.misc.ExtendedMapMode", true, Bootstrap.class.getClassLoader()); |
| 173 | + } catch (ClassNotFoundException e) { |
| 174 | + throw new RuntimeException("Unable to lookup ExtendedMapMode class", e); |
| 175 | + } |
| 176 | + } |
| 177 | + } |
| 178 | + |
161 | 179 | private void setup(boolean addShutdownHook, Environment environment) throws BootstrapException {
|
162 | 180 | Settings settings = environment.settings();
|
163 | 181 |
|
@@ -209,6 +227,8 @@ public void run() {
|
209 | 227 | // Log ifconfig output before SecurityManager is installed
|
210 | 228 | IfConfig.logIfNecessary();
|
211 | 229 |
|
| 230 | + fixJDK14EAFileChannelMap(); |
| 231 | + |
212 | 232 | // install SM after natives, shutdown hooks, etc.
|
213 | 233 | try {
|
214 | 234 | Security.configure(environment, BootstrapSettings.SECURITY_FILTER_BAD_DEFAULTS_SETTING.get(settings));
|
|
0 commit comments