mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 02:14:54 +00:00
Deprecate versions of Java prior to Java 11 (#40756)
This commit deprecates versions of Java prior to Java 11. This commit will cause a warning to be printed to standard error when any command line tool is invoked, or when Elasticsearch is started. Additionally, we log a deprecation message when Elasticsearch is started.
This commit is contained in:
parent
e64524c46f
commit
df65e46d10
@ -27,6 +27,7 @@ public class JavaVersion {
|
|||||||
|
|
||||||
public static final List<Integer> CURRENT = parse(System.getProperty("java.specification.version"));
|
public static final List<Integer> CURRENT = parse(System.getProperty("java.specification.version"));
|
||||||
public static final List<Integer> JAVA_8 = parse("1.8");
|
public static final List<Integer> JAVA_8 = parse("1.8");
|
||||||
|
public static final List<Integer> JAVA_11 = parse("11");
|
||||||
|
|
||||||
static List<Integer> parse(final String value) {
|
static List<Integer> parse(final String value) {
|
||||||
if (!value.matches("^0*[0-9]+(\\.[0-9]+)*$")) {
|
if (!value.matches("^0*[0-9]+(\\.[0-9]+)*$")) {
|
||||||
@ -66,5 +67,4 @@ public class JavaVersion {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,13 @@ final class JavaVersionChecker {
|
|||||||
errPrintln(message);
|
errPrintln(message);
|
||||||
exit(1);
|
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);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ setup() {
|
|||||||
|
|
||||||
# Verifies that no new entries in journald have been added
|
# Verifies that no new entries in journald have been added
|
||||||
# since the last start
|
# 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" ] || {
|
[ "$result" -eq "0" ] || {
|
||||||
echo "Expected no entries in journalctl for the Elasticsearch service but found:"
|
echo "Expected no entries in journalctl for the Elasticsearch service but found:"
|
||||||
journalctl _SYSTEMD_UNIT=elasticsearch.service --since "$since"
|
journalctl _SYSTEMD_UNIT=elasticsearch.service --since "$since"
|
||||||
|
@ -19,14 +19,13 @@
|
|||||||
|
|
||||||
package org.elasticsearch.bootstrap;
|
package org.elasticsearch.bootstrap;
|
||||||
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
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.Appender;
|
||||||
import org.apache.logging.log4j.core.LoggerContext;
|
import org.apache.logging.log4j.core.LoggerContext;
|
||||||
import org.apache.logging.log4j.core.appender.ConsoleAppender;
|
import org.apache.logging.log4j.core.appender.ConsoleAppender;
|
||||||
import org.apache.logging.log4j.core.config.Configurator;
|
import org.apache.logging.log4j.core.config.Configurator;
|
||||||
import org.apache.lucene.util.Constants;
|
import org.apache.lucene.util.Constants;
|
||||||
import org.elasticsearch.core.internal.io.IOUtils;
|
|
||||||
import org.apache.lucene.util.StringHelper;
|
import org.apache.lucene.util.StringHelper;
|
||||||
import org.elasticsearch.ElasticsearchException;
|
import org.elasticsearch.ElasticsearchException;
|
||||||
import org.elasticsearch.Version;
|
import org.elasticsearch.Version;
|
||||||
@ -34,6 +33,7 @@ import org.elasticsearch.cli.UserException;
|
|||||||
import org.elasticsearch.common.PidFile;
|
import org.elasticsearch.common.PidFile;
|
||||||
import org.elasticsearch.common.SuppressForbidden;
|
import org.elasticsearch.common.SuppressForbidden;
|
||||||
import org.elasticsearch.common.inject.CreationException;
|
import org.elasticsearch.common.inject.CreationException;
|
||||||
|
import org.elasticsearch.common.logging.DeprecationLogger;
|
||||||
import org.elasticsearch.common.logging.LogConfigurator;
|
import org.elasticsearch.common.logging.LogConfigurator;
|
||||||
import org.elasticsearch.common.logging.Loggers;
|
import org.elasticsearch.common.logging.Loggers;
|
||||||
import org.elasticsearch.common.network.IfConfig;
|
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.SecureSettings;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.BoundTransportAddress;
|
import org.elasticsearch.common.transport.BoundTransportAddress;
|
||||||
|
import org.elasticsearch.core.internal.io.IOUtils;
|
||||||
import org.elasticsearch.env.Environment;
|
import org.elasticsearch.env.Environment;
|
||||||
import org.elasticsearch.monitor.jvm.JvmInfo;
|
import org.elasticsearch.monitor.jvm.JvmInfo;
|
||||||
import org.elasticsearch.monitor.os.OsProbe;
|
import org.elasticsearch.monitor.os.OsProbe;
|
||||||
@ -58,6 +59,7 @@ import java.nio.file.Path;
|
|||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -295,6 +297,14 @@ final class Bootstrap {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new BootstrapException(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) {
|
if (environment.pidFile() != null) {
|
||||||
try {
|
try {
|
||||||
PidFile.create(environment.pidFile(), true);
|
PidFile.create(environment.pidFile(), true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user