diff --git a/distribution/tools/java-version-checker/src/main/java/org/elasticsearch/tools/java_version_checker/JavaVersion.java b/distribution/tools/java-version-checker/src/main/java/org/elasticsearch/tools/java_version_checker/JavaVersion.java index a06579d8425..0509b27bab8 100644 --- a/distribution/tools/java-version-checker/src/main/java/org/elasticsearch/tools/java_version_checker/JavaVersion.java +++ b/distribution/tools/java-version-checker/src/main/java/org/elasticsearch/tools/java_version_checker/JavaVersion.java @@ -27,6 +27,7 @@ public class JavaVersion { public static final List CURRENT = parse(System.getProperty("java.specification.version")); public static final List JAVA_8 = parse("1.8"); + public static final List JAVA_11 = parse("11"); static List parse(final String value) { if (!value.matches("^0*[0-9]+(\\.[0-9]+)*$")) { @@ -66,5 +67,4 @@ public class JavaVersion { return 0; } - } diff --git a/distribution/tools/java-version-checker/src/main/java/org/elasticsearch/tools/java_version_checker/JavaVersionChecker.java b/distribution/tools/java-version-checker/src/main/java/org/elasticsearch/tools/java_version_checker/JavaVersionChecker.java index b61c5856084..e0f74f8850e 100644 --- a/distribution/tools/java-version-checker/src/main/java/org/elasticsearch/tools/java_version_checker/JavaVersionChecker.java +++ b/distribution/tools/java-version-checker/src/main/java/org/elasticsearch/tools/java_version_checker/JavaVersionChecker.java @@ -48,6 +48,13 @@ final class JavaVersionChecker { errPrintln(message); exit(1); } + if (JavaVersion.compare(JavaVersion.CURRENT, JavaVersion.JAVA_11) < 0) { + final String message = String.format( + Locale.ROOT, + "future versions of Elasticsearch will require Java 11; your Java version from [%s] does not meet this requirement", + System.getProperty("java.home")); + errPrintln(message); + } exit(0); } diff --git a/qa/vagrant/src/test/resources/packaging/tests/60_systemd.bats b/qa/vagrant/src/test/resources/packaging/tests/60_systemd.bats index 8baa75f38f5..913afbe691c 100644 --- a/qa/vagrant/src/test/resources/packaging/tests/60_systemd.bats +++ b/qa/vagrant/src/test/resources/packaging/tests/60_systemd.bats @@ -106,7 +106,7 @@ setup() { # Verifies that no new entries in journald have been added # since the last start - result="$(journalctl _SYSTEMD_UNIT=elasticsearch.service --since "$since" --output cat | wc -l)" + result="$(journalctl _SYSTEMD_UNIT=elasticsearch.service --since "$since" --output cat | grep -v "future versions of Elasticsearch will require Java 11" | wc -l)" [ "$result" -eq "0" ] || { echo "Expected no entries in journalctl for the Elasticsearch service but found:" journalctl _SYSTEMD_UNIT=elasticsearch.service --since "$since" diff --git a/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java b/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java index e615dcf8ace..f9d6090f3f6 100644 --- a/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java +++ b/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java @@ -19,14 +19,13 @@ package org.elasticsearch.bootstrap; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.core.Appender; import org.apache.logging.log4j.core.LoggerContext; import org.apache.logging.log4j.core.appender.ConsoleAppender; import org.apache.logging.log4j.core.config.Configurator; import org.apache.lucene.util.Constants; -import org.elasticsearch.core.internal.io.IOUtils; import org.apache.lucene.util.StringHelper; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.Version; @@ -34,6 +33,7 @@ import org.elasticsearch.cli.UserException; import org.elasticsearch.common.PidFile; import org.elasticsearch.common.SuppressForbidden; import org.elasticsearch.common.inject.CreationException; +import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.logging.LogConfigurator; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.network.IfConfig; @@ -41,6 +41,7 @@ import org.elasticsearch.common.settings.KeyStoreWrapper; import org.elasticsearch.common.settings.SecureSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.BoundTransportAddress; +import org.elasticsearch.core.internal.io.IOUtils; import org.elasticsearch.env.Environment; import org.elasticsearch.monitor.jvm.JvmInfo; import org.elasticsearch.monitor.os.OsProbe; @@ -58,6 +59,7 @@ import java.nio.file.Path; import java.security.NoSuchAlgorithmException; import java.util.Collections; import java.util.List; +import java.util.Locale; import java.util.concurrent.CountDownLatch; /** @@ -295,6 +297,14 @@ final class Bootstrap { } catch (IOException e) { throw new BootstrapException(e); } + if (JavaVersion.current().compareTo(JavaVersion.parse("11")) < 0) { + final String message = String.format( + Locale.ROOT, + "future versions of Elasticsearch will require Java 11; " + + "your Java version from [%s] does not meet this requirement", + System.getProperty("java.home")); + new DeprecationLogger(LogManager.getLogger(Bootstrap.class)).deprecated(message); + } if (environment.pidFile() != null) { try { PidFile.create(environment.pidFile(), true);