Avoid prematurely triggering logger initialization

The class Setting holds a static reference to a deprecation logger
instance. When the class initializer for Setting runs, it starts
triggering log4j initialization. There is a chain of initializations
from InternalSettingsPreparer to Environment to Setting that triggers
this initialization before log4j configuration has occurred. This commit
modifies this initialization so that initialization is not done eagerly.

Relates #20170
This commit is contained in:
Jason Tedor 2016-08-26 05:07:05 -04:00 committed by GitHub
parent 7c9af98a3c
commit 287cb00474
1 changed files with 1 additions and 3 deletions

View File

@ -107,9 +107,6 @@ public class Setting<T> extends ToXContentToBytes {
IndexScope
}
private static final ESLogger logger = Loggers.getLogger(Setting.class);
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);
private final Key key;
protected final Function<Settings, String> defaultValue;
@Nullable
@ -322,6 +319,7 @@ public class Setting<T> extends ToXContentToBytes {
// They're using the setting, so we need to tell them to stop
if (this.isDeprecated() && this.exists(settings)) {
// It would be convenient to show its replacement key, but replacement is often not so simple
final DeprecationLogger deprecationLogger = new DeprecationLogger(Loggers.getLogger(getClass()));
deprecationLogger.deprecated("[{}] setting was deprecated in Elasticsearch and it will be removed in a future release! " +
"See the breaking changes lists in the documentation for details", getKey());
}