7070import org .elasticsearch .common .inject .ModulesBuilder ;
7171import org .elasticsearch .common .io .stream .NamedWriteableRegistry ;
7272import org .elasticsearch .common .lease .Releasables ;
73+ import org .elasticsearch .common .logging .DeprecationLogger ;
7374import org .elasticsearch .common .logging .HeaderWarning ;
7475import org .elasticsearch .common .logging .NodeAndClusterIdStateListener ;
7576import org .elasticsearch .common .network .NetworkAddress ;
@@ -252,10 +253,15 @@ public class Node implements Closeable {
252253 private final Lifecycle lifecycle = new Lifecycle ();
253254
254255 /**
255- * Logger initialized in the ctor because if it were initialized statically
256- * then it wouldn't get the node name.
256+ * This logger instance is an instance field as opposed to a static field. This ensures that the field is not
257+ * initialized until an instance of Node is constructed, which is sure to happen after the logging infrastructure
258+ * has been initialized to include the hostname. If this field were static, then it would be initialized when the
259+ * class initializer runs. Alas, this happens too early, before logging is initialized as this class is referred to
260+ * in InternalSettingsPreparer#finalizeSettings, which runs when creating the Environment, before logging is
261+ * initialized.
257262 */
258- private final Logger logger ;
263+ private final Logger logger = LogManager .getLogger (Node .class );
264+ private final DeprecationLogger deprecationLogger = DeprecationLogger .getLogger (Node .class );
259265 private final Injector injector ;
260266 private final Environment environment ;
261267 private final NodeEnvironment nodeEnvironment ;
@@ -280,7 +286,6 @@ public Node(Environment environment) {
280286 */
281287 protected Node (final Environment initialEnvironment ,
282288 Collection <Class <? extends Plugin >> classpathPlugins , boolean forbidPrivateIndexSettings ) {
283- logger = LogManager .getLogger (Node .class );
284289 final List <Closeable > resourcesToClose = new ArrayList <>(); // register everything we need to release in the case of an error
285290 boolean success = false ;
286291 try {
@@ -307,6 +312,9 @@ protected Node(final Environment initialEnvironment,
307312 logger .info ("JVM home [{}], using bundled JDK [{}]" , System .getProperty ("java.home" ), jvmInfo .getUsingBundledJdk ());
308313 } else {
309314 logger .info ("JVM home [{}]" , System .getProperty ("java.home" ));
315+ deprecationLogger .deprecate (
316+ "no-jdk" ,
317+ "no-jdk distributions that do not bundle a JDK are deprecated and will be removed in a future release" );
310318 }
311319 logger .info ("JVM arguments {}" , Arrays .toString (jvmInfo .getInputArguments ()));
312320 if (Build .CURRENT .isProductionRelease () == false ) {
0 commit comments