Browse Source

Fix weird panama integration failure (#96715)

# The issue:

VectorUtil will Load the Panama Vector incubator module if users have it enabled. However, if the first time its loaded is in a restricted security context, it will fail. There are two issues:

 - Accessing the Log4j logger (see related: https://github.com/elastic/elasticsearch/issues/93714)
 - The JDK leaking privileged access via [JDK-8309727
](https://bugs.openjdk.org/browse/JDK-8309727)

# The fix:

Eagerly load the module if supported through combining https://github.com/apache/lucene/pull/12362 with `org.elasticsearch.bootstrap.Elasticsearch#ensureInitialized.`
Benjamin Trent 2 years ago
parent
commit
a9e807a2a9

+ 4 - 1
server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java

@@ -14,6 +14,7 @@ import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.Configurator;
 import org.apache.lucene.util.Constants;
 import org.apache.lucene.util.StringHelper;
+import org.apache.lucene.util.VectorUtil;
 import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.Version;
 import org.elasticsearch.action.support.SubscribableListener;
@@ -186,7 +187,9 @@ class Elasticsearch {
             ReferenceDocs.class,
             // The following classes use MethodHandles.lookup during initialization, load them now (before SM) to be sure they succeed
             AbstractRefCounted.class,
-            SubscribableListener.class
+            SubscribableListener.class,
+            // We eagerly initialize to work around log4j permissions & JDK-8309727
+            VectorUtil.class
         );
 
         // install SM after natives, shutdown hooks, etc.