Browse Source

Silence time zone ID deprecation warning for JDK 25 due to log4j2 bug. (#134719) (#135018)

Relates to #132035
Relates to ES-12649
Moritz Mack 3 weeks ago
parent
commit
34fd8e014a

+ 9 - 4
distribution/tools/server-cli/src/main/java/org/elasticsearch/server/cli/ErrorPumpThread.java

@@ -12,6 +12,7 @@ package org.elasticsearch.server.cli;
 import org.elasticsearch.bootstrap.BootstrapInfo;
 import org.elasticsearch.cli.Terminal;
 import org.elasticsearch.cli.Terminal.Verbosity;
+import org.elasticsearch.common.regex.Regex;
 
 import java.io.BufferedReader;
 import java.io.Closeable;
@@ -19,8 +20,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.nio.charset.StandardCharsets;
-import java.util.List;
 import java.util.concurrent.CountDownLatch;
+import java.util.function.Predicate;
 
 import static org.elasticsearch.bootstrap.BootstrapInfo.SERVER_READY_MARKER;
 import static org.elasticsearch.server.cli.ProcessUtil.nonInterruptibleVoid;
@@ -84,8 +85,12 @@ class ErrorPumpThread extends Thread implements Closeable {
         nonInterruptibleVoid(this::join);
     }
 
-    /** List of messages / lines to filter from the output. */
-    List<String> filter = List.of("WARNING: Using incubator modules: jdk.incubator.vector");
+    /** Messages / lines predicate to filter from the output. */
+    private static Predicate<String> filter = Regex.simpleMatcher(
+        "WARNING: Using incubator modules: jdk.incubator.vector",
+        // requires log4j2 upgrade, see https://github.com/elastic/elasticsearch/issues/132035
+        "WARNING: Use of the three-letter time zone ID * is deprecated and it will be removed in a future release"
+    );
 
     @Override
     public void run() {
@@ -95,7 +100,7 @@ class ErrorPumpThread extends Thread implements Closeable {
                 if (line.isEmpty() == false && line.charAt(0) == SERVER_READY_MARKER) {
                     ready = true;
                     readyOrDead.countDown();
-                } else if (filter.contains(line) == false) {
+                } else if (filter.test(line) == false) {
                     terminal.errorPrintln(Verbosity.SILENT, line, false);
                 }
             }