diff --git a/distribution/src/bin/elasticsearch-env b/distribution/src/bin/elasticsearch-env index 5a54ad58e0a..6938f0e0a7a 100644 --- a/distribution/src/bin/elasticsearch-env +++ b/distribution/src/bin/elasticsearch-env @@ -92,6 +92,10 @@ ES_DISTRIBUTION_FLAVOR=${es.distribution.flavor} ES_DISTRIBUTION_TYPE=${es.distribution.type} ES_BUNDLED_JDK=${es.bundled_jdk} +if [[ "$ES_BUNDLED_JDK" == "false" ]]; then + echo "warning: no-jdk distributions that do not bundle a JDK are deprecated and will be removed in a future release" >&2 +fi + if [[ "$ES_DISTRIBUTION_TYPE" == "docker" ]]; then # Allow environment variables to be set by creating a file with the # contents, and setting an environment variable with the suffix _FILE to diff --git a/distribution/src/bin/elasticsearch-env.bat b/distribution/src/bin/elasticsearch-env.bat index 1fdb624ff68..14e2a4e164b 100644 --- a/distribution/src/bin/elasticsearch-env.bat +++ b/distribution/src/bin/elasticsearch-env.bat @@ -29,6 +29,10 @@ set ES_DISTRIBUTION_FLAVOR=${es.distribution.flavor} set ES_DISTRIBUTION_TYPE=${es.distribution.type} set ES_BUNDLED_JDK=${es.bundled_jdk} +if "%ES_BUNDLED_JDK%" == "false" ( + echo "warning: no-jdk distributions that do not bundle a JDK are deprecated and will be removed in a future release" >&2 +) + cd /d "%ES_HOME%" rem now set the path to java, pass "nojava" arg to skip setting JAVA_HOME and JAVA diff --git a/server/src/main/java/org/elasticsearch/node/Node.java b/server/src/main/java/org/elasticsearch/node/Node.java index b0212fed18d..f9fd964dac6 100644 --- a/server/src/main/java/org/elasticsearch/node/Node.java +++ b/server/src/main/java/org/elasticsearch/node/Node.java @@ -73,6 +73,7 @@ import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.ModulesBuilder; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.lease.Releasables; +import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.logging.HeaderWarning; import org.elasticsearch.common.logging.NodeAndClusterIdStateListener; import org.elasticsearch.common.network.NetworkAddress; @@ -266,10 +267,15 @@ public class Node implements Closeable { private final Lifecycle lifecycle = new Lifecycle(); /** - * Logger initialized in the ctor because if it were initialized statically - * then it wouldn't get the node name. + * This logger instance is an instance field as opposed to a static field. This ensures that the field is not + * initialized until an instance of Node is constructed, which is sure to happen after the logging infrastructure + * has been initialized to include the hostname. If this field were static, then it would be initialized when the + * class initializer runs. Alas, this happens too early, before logging is initialized as this class is referred to + * in InternalSettingsPreparer#finalizeSettings, which runs when creating the Environment, before logging is + * initialized. */ - private final Logger logger; + private final Logger logger = LogManager.getLogger(Node.class); + private final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(Node.class); private final Injector injector; private final Environment environment; private final NodeEnvironment nodeEnvironment; @@ -293,7 +299,6 @@ public class Node implements Closeable { */ protected Node(final Environment initialEnvironment, Collection> classpathPlugins, boolean forbidPrivateIndexSettings) { - logger = LogManager.getLogger(Node.class); final List resourcesToClose = new ArrayList<>(); // register everything we need to release in the case of an error boolean success = false; try { @@ -320,6 +325,9 @@ public class Node implements Closeable { logger.info("JVM home [{}], using bundled JDK [{}]", System.getProperty("java.home"), jvmInfo.getUsingBundledJdk()); } else { logger.info("JVM home [{}]", System.getProperty("java.home")); + deprecationLogger.deprecate( + "no-jdk", + "no-jdk distributions that do not bundle a JDK are deprecated and will be removed in a future release"); } logger.info("JVM arguments {}", Arrays.toString(jvmInfo.getInputArguments())); if (Build.CURRENT.isProductionRelease() == false) { diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java index 612c24cd2c6..b14a790818c 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java @@ -100,6 +100,7 @@ import org.elasticsearch.index.analysis.IndexAnalyzers; import org.elasticsearch.index.analysis.TokenFilterFactory; import org.elasticsearch.index.analysis.TokenizerFactory; import org.elasticsearch.indices.analysis.AnalysisModule; +import org.elasticsearch.monitor.jvm.JvmInfo; import org.elasticsearch.plugins.AnalysisPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.script.MockScriptEngine; @@ -415,10 +416,20 @@ public abstract class ESTestCase extends LuceneTestCase { //appropriate test try { final List warnings = threadContext.getResponseHeaders().get("Warning"); - if (warnings != null && enableJodaDeprecationWarningsCheck() == false) { - List filteredWarnings = filterJodaDeprecationWarnings(warnings); - assertThat( filteredWarnings, empty()); - + if (warnings != null) { + List filteredWarnings = new ArrayList<>(warnings); + if (enableJodaDeprecationWarningsCheck() == false) { + filteredWarnings = filterJodaDeprecationWarnings(filteredWarnings); + } + if (JvmInfo.jvmInfo().getBundledJdk() == false) { + // unit tests do not run with the bundled JDK, if there are warnings we need to filter the no-jdk deprecation warning + filteredWarnings = filteredWarnings + .stream() + .filter(k -> k.contains( + "no-jdk distributions that do not bundle a JDK are deprecated and will be removed in a future release") == false) + .collect(Collectors.toList()); + } + assertThat("unexpected warning headers", filteredWarnings, empty()); } else { assertNull("unexpected warning headers", warnings); }