Change default deprecation logger level to CRITICAL (#77030)

This commit changes default deprecation logger level to CRITICAL, where default means deprecations emitted by DeprecationLogger#critical method.
It also introduces WARN deprecations which are emitted by DeprecationLogger#warn Those log lines emitted at WARN are meant to indicate that a functionality is deprecated but will not break at next major version.
relates #76754
This commit is contained in:
Przemyslaw Gomulka 2021-09-09 12:23:52 +02:00 committed by GitHub
parent e570588a88
commit 0d3cebe812
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
125 changed files with 392 additions and 247 deletions

View file

@ -78,7 +78,7 @@ appender.header_warning.name = header_warning
################################################# #################################################
logger.deprecation.name = org.elasticsearch.deprecation logger.deprecation.name = org.elasticsearch.deprecation
logger.deprecation.level = deprecation logger.deprecation.level = WARN
logger.deprecation.appenderRef.deprecation_rolling.ref = deprecation_rolling logger.deprecation.appenderRef.deprecation_rolling.ref = deprecation_rolling
logger.deprecation.appenderRef.header_warning.ref = header_warning logger.deprecation.appenderRef.header_warning.ref = header_warning
logger.deprecation.additivity = false logger.deprecation.additivity = false

View file

@ -200,12 +200,12 @@ By default, {es} rolls and compresses deprecation logs at 1GB. The default
configuration preserves a maximum of five log files: four rolled logs and an configuration preserves a maximum of five log files: four rolled logs and an
active log. active log.
{es} emits deprecation log messages at the `DEPRECATION` level. To stop writing {es} emits deprecation log messages at the `CRITICAL` level. To stop writing
deprecation log messages, set `logger.deprecation.level` to `error`: deprecation log messages, set `logger.deprecation.level` to `OFF`:
[source,properties] [source,properties]
---- ----
logger.deprecation.level = error logger.deprecation.level = OFF
---- ----
You can identify what is triggering deprecated functionality if `X-Opaque-Id` was used as an HTTP header. You can identify what is triggering deprecated functionality if `X-Opaque-Id` was used as an HTTP header.

View file

@ -666,7 +666,7 @@ public class ConstructingObjectParserTests extends ESTestCase {
} }
private static BiConsumer<StructRemovalField, Integer> logWarningDoNothing(String old_name) { private static BiConsumer<StructRemovalField, Integer> logWarningDoNothing(String old_name) {
return (struct,value) -> deprecationLogger.compatibleApiWarning("struct_removal", return (struct,value) -> deprecationLogger.compatibleCritical("struct_removal",
"The field old_name has been removed and is being ignored"); "The field old_name has been removed and is being ignored");
} }

View file

@ -243,7 +243,7 @@ public class CommonAnalysisPlugin extends Plugin implements AnalysisPlugin, Scri
"The [edgeNGram] token filter name was deprecated in 6.4 and cannot be used in new indices. " "The [edgeNGram] token filter name was deprecated in 6.4 and cannot be used in new indices. "
+ "Please change the filter name to [edge_ngram] instead."); + "Please change the filter name to [edge_ngram] instead.");
} else { } else {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "edgeNGram_deprecation", deprecationLogger.critical(DeprecationCategory.ANALYSIS, "edgeNGram_deprecation",
"The [edgeNGram] token filter name is deprecated and will be removed in a future version. " "The [edgeNGram] token filter name is deprecated and will be removed in a future version. "
+ "Please change the filter name to [edge_ngram] instead."); + "Please change the filter name to [edge_ngram] instead.");
} }
@ -280,7 +280,7 @@ public class CommonAnalysisPlugin extends Plugin implements AnalysisPlugin, Scri
"The [nGram] token filter name was deprecated in 6.4 and cannot be used in new indices. " "The [nGram] token filter name was deprecated in 6.4 and cannot be used in new indices. "
+ "Please change the filter name to [ngram] instead."); + "Please change the filter name to [ngram] instead.");
} else { } else {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "nGram_deprecation", deprecationLogger.critical(DeprecationCategory.ANALYSIS, "nGram_deprecation",
"The [nGram] token filter name is deprecated and will be removed in a future version. " "The [nGram] token filter name is deprecated and will be removed in a future version. "
+ "Please change the filter name to [ngram] instead."); + "Please change the filter name to [ngram] instead.");
} }
@ -336,7 +336,7 @@ public class CommonAnalysisPlugin extends Plugin implements AnalysisPlugin, Scri
throw new IllegalArgumentException("The [nGram] tokenizer name was deprecated in 7.6. " throw new IllegalArgumentException("The [nGram] tokenizer name was deprecated in 7.6. "
+ "Please use the tokenizer name to [ngram] for indices created in versions 8 or higher instead."); + "Please use the tokenizer name to [ngram] for indices created in versions 8 or higher instead.");
} else if (indexSettings.getIndexVersionCreated().onOrAfter(org.elasticsearch.Version.V_7_6_0)) { } else if (indexSettings.getIndexVersionCreated().onOrAfter(org.elasticsearch.Version.V_7_6_0)) {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "nGram_tokenizer_deprecation", deprecationLogger.critical(DeprecationCategory.ANALYSIS, "nGram_tokenizer_deprecation",
"The [nGram] tokenizer name is deprecated and will be removed in a future version. " "The [nGram] tokenizer name is deprecated and will be removed in a future version. "
+ "Please change the tokenizer name to [ngram] instead."); + "Please change the tokenizer name to [ngram] instead.");
} }
@ -348,7 +348,7 @@ public class CommonAnalysisPlugin extends Plugin implements AnalysisPlugin, Scri
throw new IllegalArgumentException("The [edgeNGram] tokenizer name was deprecated in 7.6. " throw new IllegalArgumentException("The [edgeNGram] tokenizer name was deprecated in 7.6. "
+ "Please use the tokenizer name to [edge_nGram] for indices created in versions 8 or higher instead."); + "Please use the tokenizer name to [edge_nGram] for indices created in versions 8 or higher instead.");
} else if (indexSettings.getIndexVersionCreated().onOrAfter(org.elasticsearch.Version.V_7_6_0)) { } else if (indexSettings.getIndexVersionCreated().onOrAfter(org.elasticsearch.Version.V_7_6_0)) {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "edgeNGram_tokenizer_deprecation", deprecationLogger.critical(DeprecationCategory.ANALYSIS, "edgeNGram_tokenizer_deprecation",
"The [edgeNGram] tokenizer name is deprecated and will be removed in a future version. " "The [edgeNGram] tokenizer name is deprecated and will be removed in a future version. "
+ "Please change the tokenizer name to [edge_ngram] instead."); + "Please change the tokenizer name to [edge_ngram] instead.");
} }
@ -541,7 +541,7 @@ public class CommonAnalysisPlugin extends Plugin implements AnalysisPlugin, Scri
throw new IllegalArgumentException("The [nGram] tokenizer name was deprecated in 7.6. " throw new IllegalArgumentException("The [nGram] tokenizer name was deprecated in 7.6. "
+ "Please use the tokenizer name to [ngram] for indices created in versions 8 or higher instead."); + "Please use the tokenizer name to [ngram] for indices created in versions 8 or higher instead.");
} else if (version.onOrAfter(org.elasticsearch.Version.V_7_6_0)) { } else if (version.onOrAfter(org.elasticsearch.Version.V_7_6_0)) {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "nGram_tokenizer_deprecation", deprecationLogger.critical(DeprecationCategory.ANALYSIS, "nGram_tokenizer_deprecation",
"The [nGram] tokenizer name is deprecated and will be removed in a future version. " "The [nGram] tokenizer name is deprecated and will be removed in a future version. "
+ "Please change the tokenizer name to [ngram] instead."); + "Please change the tokenizer name to [ngram] instead.");
} }
@ -552,7 +552,7 @@ public class CommonAnalysisPlugin extends Plugin implements AnalysisPlugin, Scri
throw new IllegalArgumentException("The [edgeNGram] tokenizer name was deprecated in 7.6. " throw new IllegalArgumentException("The [edgeNGram] tokenizer name was deprecated in 7.6. "
+ "Please use the tokenizer name to [edge_ngram] for indices created in versions 8 or higher instead."); + "Please use the tokenizer name to [edge_ngram] for indices created in versions 8 or higher instead.");
} else if (version.onOrAfter(org.elasticsearch.Version.V_7_6_0)) { } else if (version.onOrAfter(org.elasticsearch.Version.V_7_6_0)) {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "edgeNGram_tokenizer_deprecation", deprecationLogger.critical(DeprecationCategory.ANALYSIS, "edgeNGram_tokenizer_deprecation",
"The [edgeNGram] tokenizer name is deprecated and will be removed in a future version. " "The [edgeNGram] tokenizer name is deprecated and will be removed in a future version. "
+ "Please change the tokenizer name to [edge_ngram] instead."); + "Please change the tokenizer name to [edge_ngram] instead.");
} }

View file

@ -47,7 +47,7 @@ public class SynonymTokenFilterFactory extends AbstractTokenFilterFactory {
this.settings = settings; this.settings = settings;
if (settings.get("ignore_case") != null) { if (settings.get("ignore_case") != null) {
DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_ignore_case_option", DEPRECATION_LOGGER.critical(DeprecationCategory.ANALYSIS, "synonym_ignore_case_option",
"The ignore_case option on the synonym_graph filter is deprecated. " + "The ignore_case option on the synonym_graph filter is deprecated. " +
"Instead, insert a lowercase filter in the filter chain before the synonym_graph filter."); "Instead, insert a lowercase filter in the filter chain before the synonym_graph filter.");
} }

View file

@ -193,7 +193,7 @@ public class UserAgentProcessor extends AbstractProcessor {
boolean ignoreMissing = readBooleanProperty(TYPE, processorTag, config, "ignore_missing", false); boolean ignoreMissing = readBooleanProperty(TYPE, processorTag, config, "ignore_missing", false);
Object ecsValue = config.remove("ecs"); Object ecsValue = config.remove("ecs");
if (ecsValue != null) { if (ecsValue != null) {
deprecationLogger.deprecate(DeprecationCategory.SETTINGS, "ingest_useragent_ecs_settings", deprecationLogger.critical(DeprecationCategory.SETTINGS, "ingest_useragent_ecs_settings",
"setting [ecs] is deprecated as ECS format is the default and only option"); "setting [ecs] is deprecated as ECS format is the default and only option");
} }

View file

@ -362,7 +362,7 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
} }
private static BiConsumer<PercolateQueryBuilder, String> deprecateAndIgnoreType(String key, String message) { private static BiConsumer<PercolateQueryBuilder, String> deprecateAndIgnoreType(String key, String message) {
return (target, type) -> deprecationLogger.compatibleApiWarning(key, message); return (target, type) -> deprecationLogger.compatibleCritical(key, message);
} }
private static BytesReference parseDocument(XContentParser parser) throws IOException { private static BytesReference parseDocument(XContentParser parser) throws IOException {

View file

@ -56,7 +56,7 @@ public class ReindexValidator {
state); state);
SearchSourceBuilder searchSource = request.getSearchRequest().source(); SearchSourceBuilder searchSource = request.getSearchRequest().source();
if (searchSource != null && searchSource.sorts() != null && searchSource.sorts().isEmpty() == false) { if (searchSource != null && searchSource.sorts() != null && searchSource.sorts().isEmpty() == false) {
deprecationLogger.deprecate(DeprecationCategory.API, "reindex_sort", SORT_DEPRECATED_MESSAGE); deprecationLogger.critical(DeprecationCategory.API, "reindex_sort", SORT_DEPRECATED_MESSAGE);
} }
} }

View file

@ -38,7 +38,7 @@ public class AzureDiscoveryPlugin extends Plugin implements DiscoveryPlugin {
public AzureDiscoveryPlugin(Settings settings) { public AzureDiscoveryPlugin(Settings settings) {
this.settings = settings; this.settings = settings;
deprecationLogger.deprecate(DeprecationCategory.PLUGINS, "azure_discovery_plugin", "azure classic discovery plugin is deprecated."); deprecationLogger.critical(DeprecationCategory.PLUGINS, "azure_discovery_plugin", "azure classic discovery plugin is deprecated.");
logger.trace("starting azure classic discovery plugin..."); logger.trace("starting azure classic discovery plugin...");
} }

View file

@ -125,12 +125,12 @@ final class Ec2ClientSettings {
return null; return null;
} else { } else {
if (key.length() == 0) { if (key.length() == 0) {
deprecationLogger.deprecate(DeprecationCategory.SETTINGS, "ec2_invalid_settings", deprecationLogger.critical(DeprecationCategory.SETTINGS, "ec2_invalid_settings",
"Setting [{}] is set but [{}] is not, which will be unsupported in future", "Setting [{}] is set but [{}] is not, which will be unsupported in future",
SECRET_KEY_SETTING.getKey(), ACCESS_KEY_SETTING.getKey()); SECRET_KEY_SETTING.getKey(), ACCESS_KEY_SETTING.getKey());
} }
if (secret.length() == 0) { if (secret.length() == 0) {
deprecationLogger.deprecate(DeprecationCategory.SETTINGS, "ec2_invalid_settings", deprecationLogger.critical(DeprecationCategory.SETTINGS, "ec2_invalid_settings",
"Setting [{}] is set but [{}] is not, which will be unsupported in future", "Setting [{}] is set but [{}] is not, which will be unsupported in future",
ACCESS_KEY_SETTING.getKey(), SECRET_KEY_SETTING.getKey()); ACCESS_KEY_SETTING.getKey(), SECRET_KEY_SETTING.getKey());
} }

View file

@ -21,10 +21,10 @@ import org.apache.lucene.util.Constants;
import org.elasticsearch.cli.UserException; import org.elasticsearch.cli.UserException;
import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.common.Randomness; import org.elasticsearch.common.Randomness;
import org.elasticsearch.core.PathUtils;
import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.core.PathUtils;
import org.elasticsearch.env.Environment; import org.elasticsearch.env.Environment;
import org.elasticsearch.node.Node; import org.elasticsearch.node.Node;
import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.ESTestCase;
@ -46,7 +46,6 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import static org.elasticsearch.common.logging.DeprecationLogger.DEPRECATION;
import static org.hamcrest.Matchers.endsWith; import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.hasItem;
@ -117,7 +116,7 @@ public class EvilLoggerTests extends ESTestCase {
} }
for (int j = 0; j < iterations; j++) { for (int j = 0; j < iterations; j++) {
for (final Integer id : ids) { for (final Integer id : ids) {
deprecationLogger.deprecate(DeprecationCategory.OTHER, Integer.toString(id), deprecationLogger.critical(DeprecationCategory.OTHER, Integer.toString(id),
"This is a maybe logged deprecation message" + id); "This is a maybe logged deprecation message" + id);
} }
} }
@ -171,8 +170,8 @@ public class EvilLoggerTests extends ESTestCase {
for (int i = 0; i < 128; i++) { for (int i = 0; i < 128; i++) {
assertLogLine( assertLogLine(
deprecationEvents.get(i), deprecationEvents.get(i),
DEPRECATION, DeprecationLogger.CRITICAL,
"org.elasticsearch.common.logging.DeprecationLogger.deprecate", "org.elasticsearch.common.logging.DeprecationLogger.logDeprecation",
"This is a maybe logged deprecation message" + i); "This is a maybe logged deprecation message" + i);
} }
@ -204,8 +203,8 @@ public class EvilLoggerTests extends ESTestCase {
assertThat(deprecationEvents.size(), equalTo(1)); assertThat(deprecationEvents.size(), equalTo(1));
assertLogLine( assertLogLine(
deprecationEvents.get(0), deprecationEvents.get(0),
DEPRECATION, DeprecationLogger.CRITICAL,
"org.elasticsearch.common.logging.DeprecationLogger.deprecate", "org.elasticsearch.common.logging.DeprecationLogger.logDeprecation",
"\\[deprecated.foo\\] setting was deprecated in Elasticsearch and will be removed in a future release! " + "\\[deprecated.foo\\] setting was deprecated in Elasticsearch and will be removed in a future release! " +
"See the breaking changes documentation for the next major version."); "See the breaking changes documentation for the next major version.");
} }

View file

@ -78,10 +78,35 @@ public class JsonLoggerTests extends ESTestCase {
super.tearDown(); super.tearDown();
} }
public void testDeprecationWarnMessage() throws IOException {
final DeprecationLogger testLogger = DeprecationLogger.getLogger("org.elasticsearch.test");
testLogger.warn(DeprecationCategory.OTHER, "a key", "deprecated warn message1");
final Path path = PathUtils.get(System.getProperty("es.logs.base_path"),
System.getProperty("es.logs.cluster_name") + "_deprecated.json");
try (Stream<Map<String, String>> stream = JsonLogsStream.mapStreamFrom(path)) {
List<Map<String, String>> jsonLogs = stream
.collect(Collectors.toList());
assertThat(jsonLogs, contains(
allOf(
hasEntry("log.level", "WARN"),
hasEntry("log.logger", "org.elasticsearch.deprecation.test"),
hasEntry("elasticsearch.event.category", "other"),
hasEntry("message", "deprecated warn message1")
))
);
}
assertWarnings("deprecated warn message1");
}
public void testDeprecatedMessageWithoutXOpaqueId() throws IOException { public void testDeprecatedMessageWithoutXOpaqueId() throws IOException {
final DeprecationLogger testLogger = DeprecationLogger.getLogger("org.elasticsearch.test"); final DeprecationLogger testLogger = DeprecationLogger.getLogger("org.elasticsearch.test");
testLogger.deprecate(DeprecationCategory.OTHER, "a key", "deprecated message1"); testLogger.critical(DeprecationCategory.OTHER, "a key", "deprecated message1");
final Path path = PathUtils.get(System.getProperty("es.logs.base_path"), final Path path = PathUtils.get(System.getProperty("es.logs.base_path"),
System.getProperty("es.logs.cluster_name") + "_deprecated.json"); System.getProperty("es.logs.cluster_name") + "_deprecated.json");
@ -93,7 +118,7 @@ public class JsonLoggerTests extends ESTestCase {
assertThat(jsonLogs, contains( assertThat(jsonLogs, contains(
allOf( allOf(
hasEntry("event.dataset", "deprecation.elasticsearch"), hasEntry("event.dataset", "deprecation.elasticsearch"),
hasEntry("log.level", "DEPRECATION"), hasEntry("log.level", "CRITICAL"),
hasEntry("log.logger", "org.elasticsearch.deprecation.test"), hasEntry("log.logger", "org.elasticsearch.deprecation.test"),
hasEntry("elasticsearch.cluster.name", "elasticsearch"), hasEntry("elasticsearch.cluster.name", "elasticsearch"),
hasEntry("elasticsearch.node.name", "sample-name"), hasEntry("elasticsearch.node.name", "sample-name"),
@ -117,8 +142,8 @@ public class JsonLoggerTests extends ESTestCase {
threadContext.putHeader(Task.X_OPAQUE_ID, "someId"); threadContext.putHeader(Task.X_OPAQUE_ID, "someId");
threadContext.putHeader(Task.TRACE_ID, "someTraceId"); threadContext.putHeader(Task.TRACE_ID, "someTraceId");
final DeprecationLogger testLogger = DeprecationLogger.getLogger("org.elasticsearch.test"); final DeprecationLogger testLogger = DeprecationLogger.getLogger("org.elasticsearch.test");
testLogger.deprecate(DeprecationCategory.OTHER,"someKey", "deprecated message1") testLogger.critical(DeprecationCategory.OTHER,"someKey", "deprecated message1")
.compatibleApiWarning("compatibleKey","compatible API message"); .compatibleCritical("compatibleKey","compatible API message");
final Path path = PathUtils.get( final Path path = PathUtils.get(
System.getProperty("es.logs.base_path"), System.getProperty("es.logs.base_path"),
@ -132,7 +157,7 @@ public class JsonLoggerTests extends ESTestCase {
jsonLogs, jsonLogs,
contains( contains(
allOf( allOf(
hasEntry("log.level", "DEPRECATION"), hasEntry("log.level", "CRITICAL"),
hasEntry("event.dataset", "deprecation.elasticsearch"), hasEntry("event.dataset", "deprecation.elasticsearch"),
hasEntry("data_stream.dataset", "deprecation.elasticsearch"), hasEntry("data_stream.dataset", "deprecation.elasticsearch"),
hasEntry("data_stream.namespace", "default"), hasEntry("data_stream.namespace", "default"),
@ -148,7 +173,7 @@ public class JsonLoggerTests extends ESTestCase {
hasEntry("elasticsearch.event.category", "other") hasEntry("elasticsearch.event.category", "other")
), ),
allOf( allOf(
hasEntry("log.level", "DEPRECATION"), hasEntry("log.level", "CRITICAL"),
// event.dataset and data_stream.dataset have to be the same across the data stream // event.dataset and data_stream.dataset have to be the same across the data stream
hasEntry("event.dataset", "deprecation.elasticsearch"), hasEntry("event.dataset", "deprecation.elasticsearch"),
hasEntry("data_stream.dataset", "deprecation.elasticsearch"), hasEntry("data_stream.dataset", "deprecation.elasticsearch"),
@ -200,7 +225,7 @@ public class JsonLoggerTests extends ESTestCase {
contains( contains(
// deprecation log for field deprecated_name // deprecation log for field deprecated_name
allOf( allOf(
hasEntry("log.level", "DEPRECATION"), hasEntry("log.level", "CRITICAL"),
hasEntry("event.dataset", "deprecation.elasticsearch"), hasEntry("event.dataset", "deprecation.elasticsearch"),
hasEntry("data_stream.dataset", "deprecation.elasticsearch"), hasEntry("data_stream.dataset", "deprecation.elasticsearch"),
hasEntry("data_stream.namespace", "default"), hasEntry("data_stream.namespace", "default"),
@ -217,7 +242,7 @@ public class JsonLoggerTests extends ESTestCase {
), ),
// deprecation log for field deprecated_name2 (note it is not being throttled) // deprecation log for field deprecated_name2 (note it is not being throttled)
allOf( allOf(
hasEntry("log.level", "DEPRECATION"), hasEntry("log.level", "CRITICAL"),
hasEntry("event.dataset", "deprecation.elasticsearch"), hasEntry("event.dataset", "deprecation.elasticsearch"),
hasEntry("data_stream.dataset", "deprecation.elasticsearch"), hasEntry("data_stream.dataset", "deprecation.elasticsearch"),
hasEntry("data_stream.namespace", "default"), hasEntry("data_stream.namespace", "default"),
@ -234,7 +259,7 @@ public class JsonLoggerTests extends ESTestCase {
), ),
// compatible log line // compatible log line
allOf( allOf(
hasEntry("log.level", "DEPRECATION"), hasEntry("log.level", "CRITICAL"),
hasEntry("event.dataset", "deprecation.elasticsearch"), hasEntry("event.dataset", "deprecation.elasticsearch"),
hasEntry("data_stream.dataset", "deprecation.elasticsearch"), hasEntry("data_stream.dataset", "deprecation.elasticsearch"),
hasEntry("data_stream.namespace", "default"), hasEntry("data_stream.namespace", "default"),
@ -264,7 +289,7 @@ public class JsonLoggerTests extends ESTestCase {
threadContext.putHeader(Task.X_OPAQUE_ID, "someId"); threadContext.putHeader(Task.X_OPAQUE_ID, "someId");
threadContext.putHeader(Task.TRACE_ID, "someTraceId"); threadContext.putHeader(Task.TRACE_ID, "someTraceId");
final DeprecationLogger testLogger = DeprecationLogger.getLogger("org.elasticsearch.test"); final DeprecationLogger testLogger = DeprecationLogger.getLogger("org.elasticsearch.test");
testLogger.deprecate(DeprecationCategory.OTHER, "someKey", "deprecated message1"); testLogger.critical(DeprecationCategory.OTHER, "someKey", "deprecated message1");
final Path path = PathUtils.get( final Path path = PathUtils.get(
System.getProperty("es.logs.base_path"), System.getProperty("es.logs.base_path"),
@ -279,7 +304,7 @@ public class JsonLoggerTests extends ESTestCase {
contains( contains(
allOf( allOf(
hasEntry("event.dataset", "deprecation.elasticsearch"), hasEntry("event.dataset", "deprecation.elasticsearch"),
hasEntry("log.level", "DEPRECATION"), hasEntry("log.level", "CRITICAL"),
hasEntry("log.logger", "org.elasticsearch.deprecation.test"), hasEntry("log.logger", "org.elasticsearch.deprecation.test"),
hasEntry("elasticsearch.cluster.name", "elasticsearch"), hasEntry("elasticsearch.cluster.name", "elasticsearch"),
hasEntry("elasticsearch.node.name", "sample-name"), hasEntry("elasticsearch.node.name", "sample-name"),
@ -475,8 +500,8 @@ public class JsonLoggerTests extends ESTestCase {
// For the same key and X-Opaque-ID deprecation should be once // For the same key and X-Opaque-ID deprecation should be once
withThreadContext(threadContext -> { withThreadContext(threadContext -> {
threadContext.putHeader(Task.X_OPAQUE_ID, "ID1"); threadContext.putHeader(Task.X_OPAQUE_ID, "ID1");
deprecationLogger.deprecate(DeprecationCategory.OTHER, "key", "message1"); deprecationLogger.critical(DeprecationCategory.OTHER, "key", "message1");
deprecationLogger.deprecate(DeprecationCategory.OTHER, "key", "message2"); deprecationLogger.critical(DeprecationCategory.OTHER, "key", "message2");
assertWarnings("message1", "message2"); assertWarnings("message1", "message2");
final Path path = PathUtils.get(System.getProperty("es.logs.base_path"), final Path path = PathUtils.get(System.getProperty("es.logs.base_path"),
@ -488,7 +513,7 @@ public class JsonLoggerTests extends ESTestCase {
assertThat(jsonLogs, contains( assertThat(jsonLogs, contains(
allOf( allOf(
hasEntry("event.dataset", "deprecation.elasticsearch"), hasEntry("event.dataset", "deprecation.elasticsearch"),
hasEntry("log.level", "DEPRECATION"), hasEntry("log.level", "CRITICAL"),
hasEntry("log.logger", "org.elasticsearch.deprecation.test"), hasEntry("log.logger", "org.elasticsearch.deprecation.test"),
hasEntry("elasticsearch.cluster.name", "elasticsearch"), hasEntry("elasticsearch.cluster.name", "elasticsearch"),
hasEntry("elasticsearch.node.name", "sample-name"), hasEntry("elasticsearch.node.name", "sample-name"),
@ -504,8 +529,8 @@ public class JsonLoggerTests extends ESTestCase {
//continuing with message1-ID1 in logs already, adding a new deprecation log line with message2-ID2 //continuing with message1-ID1 in logs already, adding a new deprecation log line with message2-ID2
withThreadContext(threadContext -> { withThreadContext(threadContext -> {
threadContext.putHeader(Task.X_OPAQUE_ID, "ID2"); threadContext.putHeader(Task.X_OPAQUE_ID, "ID2");
deprecationLogger.deprecate(DeprecationCategory.OTHER, "key", "message1"); deprecationLogger.critical(DeprecationCategory.OTHER, "key", "message1");
deprecationLogger.deprecate(DeprecationCategory.OTHER, "key", "message2"); deprecationLogger.critical(DeprecationCategory.OTHER, "key", "message2");
assertWarnings("message1", "message2"); assertWarnings("message1", "message2");
final Path path = PathUtils.get( final Path path = PathUtils.get(
@ -520,7 +545,7 @@ public class JsonLoggerTests extends ESTestCase {
contains( contains(
allOf( allOf(
hasEntry("event.dataset", "deprecation.elasticsearch"), hasEntry("event.dataset", "deprecation.elasticsearch"),
hasEntry("log.level", "DEPRECATION"), hasEntry("log.level", "CRITICAL"),
hasEntry("log.logger", "org.elasticsearch.deprecation.test"), hasEntry("log.logger", "org.elasticsearch.deprecation.test"),
hasEntry("elasticsearch.cluster.name", "elasticsearch"), hasEntry("elasticsearch.cluster.name", "elasticsearch"),
hasEntry("elasticsearch.node.name", "sample-name"), hasEntry("elasticsearch.node.name", "sample-name"),
@ -530,7 +555,7 @@ public class JsonLoggerTests extends ESTestCase {
), ),
allOf( allOf(
hasEntry("event.dataset", "deprecation.elasticsearch"), hasEntry("event.dataset", "deprecation.elasticsearch"),
hasEntry("log.level", "DEPRECATION"), hasEntry("log.level", "CRITICAL"),
hasEntry("log.logger", "org.elasticsearch.deprecation.test"), hasEntry("log.logger", "org.elasticsearch.deprecation.test"),
hasEntry("elasticsearch.cluster.name", "elasticsearch"), hasEntry("elasticsearch.cluster.name", "elasticsearch"),
hasEntry("elasticsearch.node.name", "sample-name"), hasEntry("elasticsearch.node.name", "sample-name"),

View file

@ -40,7 +40,7 @@ appender.header_warning.type = HeaderWarningAppender
appender.header_warning.name = header_warning appender.header_warning.name = header_warning
logger.deprecation.name = org.elasticsearch.deprecation logger.deprecation.name = org.elasticsearch.deprecation
logger.deprecation.level = deprecation logger.deprecation.level = WARN
logger.deprecation.appenderRef.deprecation_rolling.ref = deprecated logger.deprecation.appenderRef.deprecation_rolling.ref = deprecated
logger.deprecation.appenderRef.deprecatedconsole.ref = deprecatedconsole logger.deprecation.appenderRef.deprecatedconsole.ref = deprecatedconsole
logger.deprecation.appenderRef.header_warning.ref = header_warning logger.deprecation.appenderRef.header_warning.ref = header_warning

View file

@ -364,7 +364,7 @@ public class SystemIndicesSnapshotIT extends AbstractSnapshotIntegTestCase {
new MockLogAppender.SeenEventExpectation( new MockLogAppender.SeenEventExpectation(
"restore-system-index-from-snapshot", "restore-system-index-from-snapshot",
"org.elasticsearch.deprecation.snapshots.RestoreService", "org.elasticsearch.deprecation.snapshots.RestoreService",
DeprecationLogger.DEPRECATION, DeprecationLogger.CRITICAL,
"Restoring system indices by name is deprecated. Use feature states instead. System indices: [.test-system-idx]" "Restoring system indices by name is deprecated. Use feature states instead. System indices: [.test-system-idx]"
) )
); );

View file

@ -150,7 +150,7 @@ public class TransportGetAliasesAction extends TransportMasterNodeReadAction<Get
} }
} }
if (systemIndicesNames.isEmpty() == false) { if (systemIndicesNames.isEmpty() == false) {
deprecationLogger.deprecate(DeprecationCategory.API, "open_system_index_access", deprecationLogger.critical(DeprecationCategory.API, "open_system_index_access",
"this request accesses system indices: {}, but in a future major version, direct access to system " + "this request accesses system indices: {}, but in a future major version, direct access to system " +
"indices will be prevented by default", systemIndicesNames); "indices will be prevented by default", systemIndicesNames);
} }
@ -186,7 +186,7 @@ public class TransportGetAliasesAction extends TransportMasterNodeReadAction<Get
} }
if (systemAliases.isEmpty() == false) { if (systemAliases.isEmpty() == false) {
deprecationLogger.deprecate(DeprecationCategory.API, "open_system_alias_access", deprecationLogger.critical(DeprecationCategory.API, "open_system_alias_access",
"this request accesses aliases with names reserved for system indices: {}, but in a future major version, direct " + "this request accesses aliases with names reserved for system indices: {}, but in a future major version, direct " +
"access to system indices and their aliases will not be allowed", systemAliases); "access to system indices and their aliases will not be allowed", systemAliases);
} }

View file

@ -187,7 +187,7 @@ public final class BulkRequestParser {
if (parser.getRestApiVersion().matches(RestApiVersion.equalTo(RestApiVersion.V_7))) { if (parser.getRestApiVersion().matches(RestApiVersion.equalTo(RestApiVersion.V_7))) {
// for bigger bulks, deprecation throttling might not be enough // for bigger bulks, deprecation throttling might not be enough
if (deprecateOrErrorOnType && typesDeprecationLogged == false) { if (deprecateOrErrorOnType && typesDeprecationLogged == false) {
deprecationLogger.compatibleApiWarning("bulk_with_types", deprecationLogger.compatibleCritical("bulk_with_types",
RestBulkAction.TYPES_DEPRECATION_MESSAGE); RestBulkAction.TYPES_DEPRECATION_MESSAGE);
typesDeprecationLogged = true; typesDeprecationLogged = true;
} }

View file

@ -392,7 +392,7 @@ public class MultiGetRequest extends ActionRequest
id = parser.text(); id = parser.text();
} else if(parser.getRestApiVersion() == RestApiVersion.V_7 && } else if(parser.getRestApiVersion() == RestApiVersion.V_7 &&
TYPE.match(currentFieldName,parser.getDeprecationHandler())) { TYPE.match(currentFieldName,parser.getDeprecationHandler())) {
deprecationLogger.compatibleApiWarning("mget_with_types", RestMultiGetAction.TYPES_DEPRECATION_MESSAGE); deprecationLogger.compatibleCritical("mget_with_types", RestMultiGetAction.TYPES_DEPRECATION_MESSAGE);
} else if (ROUTING.match(currentFieldName, parser.getDeprecationHandler())) { } else if (ROUTING.match(currentFieldName, parser.getDeprecationHandler())) {
routing = parser.text(); routing = parser.text();
} else if (FIELDS.match(currentFieldName, parser.getDeprecationHandler())) { } else if (FIELDS.match(currentFieldName, parser.getDeprecationHandler())) {

View file

@ -197,7 +197,7 @@ public class MultiGetResponse extends ActionResponse implements Iterable<MultiGe
if (INDEX.match(currentFieldName, parser.getDeprecationHandler())) { if (INDEX.match(currentFieldName, parser.getDeprecationHandler())) {
index = parser.text(); index = parser.text();
} else if (TYPE.match(currentFieldName, parser.getDeprecationHandler())) { } else if (TYPE.match(currentFieldName, parser.getDeprecationHandler())) {
deprecationLogger.compatibleApiWarning("mget_with_types", RestMultiGetAction.TYPES_DEPRECATION_MESSAGE); deprecationLogger.compatibleCritical("mget_with_types", RestMultiGetAction.TYPES_DEPRECATION_MESSAGE);
} else if (ID.match(currentFieldName, parser.getDeprecationHandler())) { } else if (ID.match(currentFieldName, parser.getDeprecationHandler())) {
id = parser.text(); id = parser.text();
} }

View file

@ -187,7 +187,7 @@ public class SimulatePipelineRequest extends ActionRequest implements ToXContent
String routing = ConfigurationUtils.readOptionalStringOrIntProperty(null, null, String routing = ConfigurationUtils.readOptionalStringOrIntProperty(null, null,
dataMap, Metadata.ROUTING.getFieldName()); dataMap, Metadata.ROUTING.getFieldName());
if (restApiVersion == RestApiVersion.V_7 && dataMap.containsKey(Metadata.TYPE.getFieldName())) { if (restApiVersion == RestApiVersion.V_7 && dataMap.containsKey(Metadata.TYPE.getFieldName())) {
deprecationLogger.compatibleApiWarning("simulate_pipeline_with_types", deprecationLogger.compatibleCritical("simulate_pipeline_with_types",
"[types removal] specifying _type in pipeline simulation requests is deprecated"); "[types removal] specifying _type in pipeline simulation requests is deprecated");
} }
Long version = null; Long version = null;

View file

@ -189,7 +189,7 @@ public class MultiSearchRequest extends ActionRequest implements CompositeIndice
} }
// support first line with \n // support first line with \n
if (restApiVersion == RestApiVersion.V_7 && nextMarker == 0) { if (restApiVersion == RestApiVersion.V_7 && nextMarker == 0) {
deprecationLogger.compatibleApiWarning("msearch_first_line_empty", FIRST_LINE_EMPTY_DEPRECATION_MESSAGE); deprecationLogger.compatibleCritical("msearch_first_line_empty", FIRST_LINE_EMPTY_DEPRECATION_MESSAGE);
from = nextMarker + 1; from = nextMarker + 1;
continue; continue;
} }
@ -250,7 +250,7 @@ public class MultiSearchRequest extends ActionRequest implements CompositeIndice
ignoreThrottled = value; ignoreThrottled = value;
} else if(restApiVersion == RestApiVersion.V_7 && } else if(restApiVersion == RestApiVersion.V_7 &&
("type".equals(entry.getKey()) || "types".equals(entry.getKey()))) { ("type".equals(entry.getKey()) || "types".equals(entry.getKey()))) {
deprecationLogger.compatibleApiWarning("msearch_with_types", RestMultiSearchAction.TYPES_DEPRECATION_MESSAGE); deprecationLogger.compatibleCritical("msearch_with_types", RestMultiSearchAction.TYPES_DEPRECATION_MESSAGE);
} else { } else {
throw new IllegalArgumentException("key [" + entry.getKey() + "] is not supported in the metadata section"); throw new IllegalArgumentException("key [" + entry.getKey() + "] is not supported in the metadata section");
} }

View file

@ -580,7 +580,7 @@ public class TermVectorsRequest extends SingleShardRequest<TermVectorsRequest> i
} else if (VERSION_TYPE.match(currentFieldName, parser.getDeprecationHandler())) { } else if (VERSION_TYPE.match(currentFieldName, parser.getDeprecationHandler())) {
termVectorsRequest.versionType = VersionType.fromString(parser.text()); termVectorsRequest.versionType = VersionType.fromString(parser.text());
} else if (restApiVersion == RestApiVersion.V_7 && TYPE.match(currentFieldName, parser.getDeprecationHandler())) { } else if (restApiVersion == RestApiVersion.V_7 && TYPE.match(currentFieldName, parser.getDeprecationHandler())) {
deprecationLogger.compatibleApiWarning("termvectors_with_types", deprecationLogger.compatibleCritical("termvectors_with_types",
RestTermVectorsAction.TYPES_DEPRECATION_MESSAGE); RestTermVectorsAction.TYPES_DEPRECATION_MESSAGE);
} else { } else {
throw new ElasticsearchParseException("failed to parse term vectors request. unknown field [{}]", currentFieldName); throw new ElasticsearchParseException("failed to parse term vectors request. unknown field [{}]", currentFieldName);

View file

@ -352,7 +352,7 @@ public class IndexNameExpressionResolver {
if (resolvedSystemIndices.isEmpty() == false) { if (resolvedSystemIndices.isEmpty() == false) {
Collections.sort(resolvedSystemIndices); Collections.sort(resolvedSystemIndices);
deprecationLogger.deprecate(DeprecationCategory.API, "open_system_index_access", deprecationLogger.critical(DeprecationCategory.API, "open_system_index_access",
"this request accesses system indices: {}, but in a future major version, direct access to system " + "this request accesses system indices: {}, but in a future major version, direct access to system " +
"indices will be prevented by default", resolvedSystemIndices); "indices will be prevented by default", resolvedSystemIndices);
} }

View file

@ -204,7 +204,7 @@ public class MetadataCreateIndexService {
} else if (isHidden) { } else if (isHidden) {
logger.trace("index [{}] is a hidden index", index); logger.trace("index [{}] is a hidden index", index);
} else { } else {
deprecationLogger.deprecate(DeprecationCategory.INDICES, "index_name_starts_with_dot", deprecationLogger.critical(DeprecationCategory.INDICES, "index_name_starts_with_dot",
"index name [{}] starts with a dot '.', in the next major version, index names " + "index name [{}] starts with a dot '.', in the next major version, index names " +
"starting with a dot are reserved for hidden indices and system indices", index); "starting with a dot are reserved for hidden indices and system indices", index);
} }
@ -366,7 +366,7 @@ public class MetadataCreateIndexService {
request.index(), isHiddenFromRequest); request.index(), isHiddenFromRequest);
if (v1Templates.size() > 1) { if (v1Templates.size() > 1) {
deprecationLogger.deprecate(DeprecationCategory.TEMPLATES, "index_template_multiple_match", deprecationLogger.critical(DeprecationCategory.TEMPLATES, "index_template_multiple_match",
"index [{}] matches multiple legacy templates [{}], composable templates will only match a single template", "index [{}] matches multiple legacy templates [{}], composable templates will only match a single template",
request.index(), v1Templates.stream().map(IndexTemplateMetadata::name).sorted().collect(Collectors.joining(", "))); request.index(), v1Templates.stream().map(IndexTemplateMetadata::name).sorted().collect(Collectors.joining(", ")));
} }
@ -1274,7 +1274,7 @@ public class MetadataCreateIndexService {
if (IndexSettings.INDEX_SOFT_DELETES_SETTING.get(indexSettings) && if (IndexSettings.INDEX_SOFT_DELETES_SETTING.get(indexSettings) &&
(IndexSettings.INDEX_TRANSLOG_RETENTION_AGE_SETTING.exists(indexSettings) (IndexSettings.INDEX_TRANSLOG_RETENTION_AGE_SETTING.exists(indexSettings)
|| IndexSettings.INDEX_TRANSLOG_RETENTION_SIZE_SETTING.exists(indexSettings))) { || IndexSettings.INDEX_TRANSLOG_RETENTION_SIZE_SETTING.exists(indexSettings))) {
deprecationLogger.deprecate( deprecationLogger.critical(
DeprecationCategory.SETTINGS, DeprecationCategory.SETTINGS,
"translog_retention", "translog_retention",
"Translog retention settings [index.translog.retention.age] and [index.translog.retention.size] are deprecated and " "Translog retention settings [index.translog.retention.age] and [index.translog.retention.size] are deprecated and "
@ -1286,7 +1286,7 @@ public class MetadataCreateIndexService {
public static void validateStoreTypeSetting(Settings indexSettings) { public static void validateStoreTypeSetting(Settings indexSettings) {
final String storeType = IndexModule.INDEX_STORE_TYPE_SETTING.get(indexSettings); final String storeType = IndexModule.INDEX_STORE_TYPE_SETTING.get(indexSettings);
if (IndexModule.Type.SIMPLEFS.match(storeType)) { if (IndexModule.Type.SIMPLEFS.match(storeType)) {
deprecationLogger.deprecate(DeprecationCategory.SETTINGS, "store_type_setting", deprecationLogger.critical(DeprecationCategory.SETTINGS, "store_type_setting",
"[simplefs] is deprecated and will be removed in 8.0. Use [niofs] or other file systems instead. " + "[simplefs] is deprecated and will be removed in 8.0. Use [niofs] or other file systems instead. " +
"Elasticsearch 7.15 or later uses [niofs] for the [simplefs] store type as it offers superior " + "Elasticsearch 7.15 or later uses [niofs] for the [simplefs] store type as it offers superior " +
"or equivalent performance to [simplefs]."); "or equivalent performance to [simplefs].");

View file

@ -264,16 +264,16 @@ public class Joda {
private static void maybeLogJodaDeprecation(String input) { private static void maybeLogJodaDeprecation(String input) {
if (input.contains("CC")) { if (input.contains("CC")) {
getDeprecationLogger().deprecate(DeprecationCategory.PARSING, "joda-century-of-era-format", getDeprecationLogger().critical(DeprecationCategory.PARSING, "joda-century-of-era-format",
"Use of 'C' (century-of-era) is deprecated and will not be supported in the next major version of Elasticsearch."); "Use of 'C' (century-of-era) is deprecated and will not be supported in the next major version of Elasticsearch.");
} }
if (input.contains("YY")) { if (input.contains("YY")) {
getDeprecationLogger().deprecate(DeprecationCategory.PARSING, "joda-year-of-era-format", getDeprecationLogger().critical(DeprecationCategory.PARSING, "joda-year-of-era-format",
"Use of 'Y' (year-of-era) will change to 'y' in the" + "Use of 'Y' (year-of-era) will change to 'y' in the" +
" next major version of Elasticsearch. Prefix your date format with '8' to use the new specifier."); " next major version of Elasticsearch. Prefix your date format with '8' to use the new specifier.");
} }
if (input.contains("xx")) { if (input.contains("xx")) {
getDeprecationLogger().deprecate(DeprecationCategory.PARSING, "joda-week-based-year-format", getDeprecationLogger().critical(DeprecationCategory.PARSING, "joda-week-based-year-format",
"Use of 'x' (week-based-year) will change" + "Use of 'x' (week-based-year) will change" +
" to 'Y' in the next major version of Elasticsearch. Prefix your date format with '8' to use the new specifier."); " to 'Y' in the next major version of Elasticsearch. Prefix your date format with '8' to use the new specifier.");
} }
@ -372,11 +372,11 @@ public class Joda {
long millis = new BigDecimal(text).longValue() * factor; long millis = new BigDecimal(text).longValue() * factor;
// check for deprecations, but after it has parsed correctly so invalid values aren't counted as deprecated // check for deprecations, but after it has parsed correctly so invalid values aren't counted as deprecated
if (millis < 0) { if (millis < 0) {
getDeprecationLogger().deprecate(DeprecationCategory.PARSING, "epoch-negative", "Use of negative values" + getDeprecationLogger().critical(DeprecationCategory.PARSING, "epoch-negative", "Use of negative values" +
" in epoch time formats is deprecated and will not be supported in the next major version of Elasticsearch."); " in epoch time formats is deprecated and will not be supported in the next major version of Elasticsearch.");
} }
if (scientificNotation.matcher(text).find()) { if (scientificNotation.matcher(text).find()) {
getDeprecationLogger().deprecate(DeprecationCategory.PARSING, "epoch-scientific-notation", getDeprecationLogger().critical(DeprecationCategory.PARSING, "epoch-scientific-notation",
"Use of scientific notation" + "Use of scientific notation" +
" in epoch time formats is deprecated and will not be supported in the next major version of Elasticsearch."); " in epoch time formats is deprecated and will not be supported in the next major version of Elasticsearch.");
} }

View file

@ -13,12 +13,12 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
/** /**
* A logger that logs deprecation notices. Logger should be initialized with a parent logger which name will be used * A logger that logs deprecation notices. Logger should be initialized with a class or name which will be used
* for deprecation logger. For instance <code>DeprecationLogger.getLogger("org.elasticsearch.test.SomeClass")</code> will * for deprecation logger. For instance <code>DeprecationLogger.getLogger("org.elasticsearch.test.SomeClass")</code> will
* result in a deprecation logger with name <code>org.elasticsearch.deprecation.test.SomeClass</code>. This allows to use a * result in a deprecation logger with name <code>org.elasticsearch.deprecation.test.SomeClass</code>. This allows to use a
* <code>deprecation</code> logger defined in log4j2.properties. * <code>deprecation</code> logger defined in log4j2.properties.
* <p> * <p>
* Logs are emitted at the custom {@link #DEPRECATION} level, and routed wherever they need to go using log4j. For example, * Logs are emitted at the custom {@link #CRITICAL} level, and routed wherever they need to go using log4j. For example,
* to disk using a rolling file appender, or added as a response header using {@link HeaderWarningAppender}. * to disk using a rolling file appender, or added as a response header using {@link HeaderWarningAppender}.
* <p> * <p>
* Deprecation messages include a <code>key</code>, which is used for rate-limiting purposes. The log4j configuration * Deprecation messages include a <code>key</code>, which is used for rate-limiting purposes. The log4j configuration
@ -27,11 +27,12 @@ import org.apache.logging.log4j.Logger;
* message limiting. * message limiting.
*/ */
public class DeprecationLogger { public class DeprecationLogger {
/** /**
* Deprecation messages are logged at this level. * Deprecation messages are logged at this level.
* More serious that WARN by 1, but less serious than ERROR
*/ */
public static Level DEPRECATION = Level.forName("DEPRECATION", Level.WARN.intLevel() + 1); public static Level CRITICAL = Level.forName("CRITICAL", Level.WARN.intLevel() - 1);
private final Logger logger; private final Logger logger;
@ -72,29 +73,55 @@ public class DeprecationLogger {
} }
/** /**
* Logs a message at the {@link #DEPRECATION} level. The message is also sent to the header warning logger, * Logs a message at the {@link DeprecationLogger#CRITICAL} level.
* This log will indicate that a change will break in next version.
* The message is also sent to the header warning logger,
* so that it can be returned to the client. * so that it can be returned to the client.
*/ */
public DeprecationLogger deprecate( public DeprecationLogger critical(
final DeprecationCategory category, final DeprecationCategory category,
final String key, final String key,
final String msg, final String msg,
final Object... params final Object... params) {
) { return logDeprecation(CRITICAL, category, key, msg, params);
}
/**
* Logs a message at the {@link Level#WARN} level for less critical deprecations
* that won't break in next version.
* The message is also sent to the header warning logger,
* so that it can be returned to the client.
*/
public DeprecationLogger warn(
final DeprecationCategory category,
final String key,
final String msg,
final Object... params) {
return logDeprecation(Level.WARN, category, key, msg, params);
}
private DeprecationLogger logDeprecation(Level level, DeprecationCategory category, String key, String msg, Object[] params) {
assert category != DeprecationCategory.COMPATIBLE_API : assert category != DeprecationCategory.COMPATIBLE_API :
"DeprecationCategory.COMPATIBLE_API should be logged with compatibleApiWarning method"; "DeprecationCategory.COMPATIBLE_API should be logged with compatibleApiWarning method";
ESLogMessage deprecationMessage = DeprecatedMessage.of(category, key, HeaderWarning.getXOpaqueId(), msg, params); ESLogMessage deprecationMessage = DeprecatedMessage.of(category, key, HeaderWarning.getXOpaqueId(), msg, params);
logger.log(DEPRECATION, deprecationMessage); logger.log(level, deprecationMessage);
return this; return this;
} }
public DeprecationLogger compatibleApiWarning( /**
* Used for handling previous version RestApiCompatible logic.
* Logs a message at the {@link DeprecationLogger#CRITICAL} level
* that have been broken in previous version.
* The message is also sent to the header warning logger,
* so that it can be returned to the client.
*/
public DeprecationLogger compatibleCritical(
final String key, final String key,
final String msg, final String msg,
final Object... params) { final Object... params) {
String opaqueId = HeaderWarning.getXOpaqueId(); String opaqueId = HeaderWarning.getXOpaqueId();
ESLogMessage deprecationMessage = DeprecatedMessage.compatibleDeprecationMessage(key, opaqueId, msg, params); ESLogMessage deprecationMessage = DeprecatedMessage.compatibleDeprecationMessage(key, opaqueId, msg, params);
logger.log(DEPRECATION, deprecationMessage); logger.log(CRITICAL, deprecationMessage);
return this; return this;
} }

View file

@ -548,7 +548,7 @@ public class Setting<T> implements ToXContentObject {
// It would be convenient to show its replacement key, but replacement is often not so simple // It would be convenient to show its replacement key, but replacement is often not so simple
final String key = getKey(); final String key = getKey();
Settings.DeprecationLoggerHolder.deprecationLogger Settings.DeprecationLoggerHolder.deprecationLogger
.deprecate(DeprecationCategory.SETTINGS, key, .critical(DeprecationCategory.SETTINGS, key,
"[{}] setting was deprecated in Elasticsearch and will be removed in a future release! " "[{}] setting was deprecated in Elasticsearch and will be removed in a future release! "
+ "See the breaking changes documentation for the next major version.", key); + "See the breaking changes documentation for the next major version.", key);
} }

View file

@ -190,7 +190,7 @@ public class DateUtils {
public static ZoneId of(String zoneId) { public static ZoneId of(String zoneId) {
String deprecatedId = DEPRECATED_SHORT_TIMEZONES.get(zoneId); String deprecatedId = DEPRECATED_SHORT_TIMEZONES.get(zoneId);
if (deprecatedId != null) { if (deprecatedId != null) {
deprecationLogger.deprecate(DeprecationCategory.PARSING, "timezone", deprecationLogger.critical(DeprecationCategory.PARSING, "timezone",
"Use of short timezone id " + zoneId + " is deprecated. Use " + deprecatedId + " instead"); "Use of short timezone id " + zoneId + " is deprecated. Use " + deprecatedId + " instead");
return ZoneId.of(deprecatedId); return ZoneId.of(deprecatedId);
} }

View file

@ -261,7 +261,7 @@ public class ByteSizeValue implements Writeable, Comparable<ByteSizeValue>, ToXC
try { try {
final double doubleValue = Double.parseDouble(s); final double doubleValue = Double.parseDouble(s);
DeprecationLoggerHolder.deprecationLogger DeprecationLoggerHolder.deprecationLogger
.deprecate(DeprecationCategory.PARSING, "fractional_byte_values", .critical(DeprecationCategory.PARSING, "fractional_byte_values",
"Fractional bytes values are deprecated. Use non-fractional bytes values instead: [{}] found for setting [{}]", "Fractional bytes values are deprecated. Use non-fractional bytes values instead: [{}] found for setting [{}]",
initialInput, settingName); initialInput, settingName);
return new ByteSizeValue((long) (doubleValue * unit.toBytes(1))); return new ByteSizeValue((long) (doubleValue * unit.toBytes(1)));

View file

@ -37,10 +37,10 @@ public class LoggingDeprecationHandler implements DeprecationHandler {
public static final LoggingDeprecationHandler INSTANCE = new LoggingDeprecationHandler(); public static final LoggingDeprecationHandler INSTANCE = new LoggingDeprecationHandler();
private TriConsumer<String, Object[], String> deprecationLoggerFunction = (message, params, field_name) -> private TriConsumer<String, Object[], String> deprecationLoggerFunction = (message, params, field_name) ->
deprecationLogger.deprecate(DeprecationCategory.API, "deprecated_field_" + field_name, message, params); deprecationLogger.critical(DeprecationCategory.API, "deprecated_field_" + field_name, message, params);
private TriConsumer<String, Object[], String> compatibleLoggerFunction = (message, params, field_name) -> private TriConsumer<String, Object[], String> compatibleLoggerFunction = (message, params, field_name) ->
deprecationLogger.compatibleApiWarning("deprecated_field_" + field_name, message, params); deprecationLogger.compatibleCritical("deprecated_field_" + field_name, message, params);
private LoggingDeprecationHandler() { private LoggingDeprecationHandler() {
// one instance only // one instance only

View file

@ -190,7 +190,7 @@ public final class IndexSortConfig {
if (this.indexCreatedVersion.onOrAfter(Version.V_7_13_0)) { if (this.indexCreatedVersion.onOrAfter(Version.V_7_13_0)) {
throw new IllegalArgumentException("Cannot use alias [" + sortSpec.field + "] as an index sort field"); throw new IllegalArgumentException("Cannot use alias [" + sortSpec.field + "] as an index sort field");
} else { } else {
DEPRECATION_LOGGER.deprecate( DEPRECATION_LOGGER.critical(
DeprecationCategory.MAPPINGS, DeprecationCategory.MAPPINGS,
"index-sort-aliases", "index-sort-aliases",
"Index sort for index [" + indexName + "] defined on field [" + sortSpec.field + "Index sort for index [" + indexName + "] defined on field [" + sortSpec.field +

View file

@ -72,7 +72,7 @@ public class Analysis {
public static void checkForDeprecatedVersion(String name, Settings settings) { public static void checkForDeprecatedVersion(String name, Settings settings) {
String sVersion = settings.get("version"); String sVersion = settings.get("version");
if (sVersion != null) { if (sVersion != null) {
DEPRECATION_LOGGER.deprecate( DEPRECATION_LOGGER.critical(
DeprecationCategory.ANALYSIS, DeprecationCategory.ANALYSIS,
"analyzer.version", "analyzer.version",
"Setting [version] on analysis component [" + name + "] has no effect and is deprecated" "Setting [version] on analysis component [" + name + "] has no effect and is deprecated"

View file

@ -39,7 +39,7 @@ public class ShingleTokenFilterFactory extends AbstractTokenFilterFactory {
+ " must be less than or equal to: [" + maxAllowedShingleDiff + "] but was [" + shingleDiff + "]. This limit" + " must be less than or equal to: [" + maxAllowedShingleDiff + "] but was [" + shingleDiff + "]. This limit"
+ " can be set by changing the [" + IndexSettings.MAX_SHINGLE_DIFF_SETTING.getKey() + "] index level setting."); + " can be set by changing the [" + IndexSettings.MAX_SHINGLE_DIFF_SETTING.getKey() + "] index level setting.");
} else { } else {
DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "excessive_shingle_diff", DEPRECATION_LOGGER.critical(DeprecationCategory.ANALYSIS, "excessive_shingle_diff",
"Deprecated big difference between maxShingleSize and minShingleSize" + "Deprecated big difference between maxShingleSize and minShingleSize" +
" in Shingle TokenFilter, expected difference must be less than or equal to: [" + maxAllowedShingleDiff + "]"); " in Shingle TokenFilter, expected difference must be less than or equal to: [" + maxAllowedShingleDiff + "]");
} }
@ -65,7 +65,7 @@ public class ShingleTokenFilterFactory extends AbstractTokenFilterFactory {
"] cannot be used to parse synonyms"); "] cannot be used to parse synonyms");
} }
else { else {
DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters", "Token filter " + name() DEPRECATION_LOGGER.critical(DeprecationCategory.ANALYSIS, "synonym_tokenfilters", "Token filter " + name()
+ "] will not be usable to parse synonym after v7.0"); + "] will not be usable to parse synonym after v7.0");
} }
return this; return this;

View file

@ -327,7 +327,7 @@ public class GetResult implements Writeable, Iterable<DocumentField>, ToXContent
if (_INDEX.equals(currentFieldName)) { if (_INDEX.equals(currentFieldName)) {
index = parser.text(); index = parser.text();
} else if (parser.getRestApiVersion() == RestApiVersion.V_7 && MapperService.TYPE_FIELD_NAME.equals(currentFieldName)) { } else if (parser.getRestApiVersion() == RestApiVersion.V_7 && MapperService.TYPE_FIELD_NAME.equals(currentFieldName)) {
deprecationLogger.compatibleApiWarning("mget_with_types", RestMultiGetAction.TYPES_DEPRECATION_MESSAGE); deprecationLogger.compatibleCritical("mget_with_types", RestMultiGetAction.TYPES_DEPRECATION_MESSAGE);
} else if (_ID.equals(currentFieldName)) { } else if (_ID.equals(currentFieldName)) {
id = parser.text(); id = parser.text();
} else if (_VERSION.equals(currentFieldName)) { } else if (_VERSION.equals(currentFieldName)) {

View file

@ -189,7 +189,7 @@ public class CompletionFieldMapper extends FieldMapper {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Limit of completion field contexts [" + COMPLETION_CONTEXTS_LIMIT + "] has been exceeded"); "Limit of completion field contexts [" + COMPLETION_CONTEXTS_LIMIT + "] has been exceeded");
} else { } else {
deprecationLogger.deprecate(DeprecationCategory.MAPPINGS, "excessive_completion_contexts", deprecationLogger.critical(DeprecationCategory.MAPPINGS, "excessive_completion_contexts",
"You have defined more than [" + COMPLETION_CONTEXTS_LIMIT + "] completion contexts" + "You have defined more than [" + COMPLETION_CONTEXTS_LIMIT + "] completion contexts" +
" in the mapping for field [" + name() + "]. " + " in the mapping for field [" + name() + "]. " +
"The maximum allowed number of completion contexts in a mapping will be limited to " + "The maximum allowed number of completion contexts in a mapping will be limited to " +

View file

@ -295,7 +295,7 @@ public final class DateFieldMapper extends FieldMapper {
if (indexCreatedVersion.onOrAfter(Version.V_8_0_0)) { if (indexCreatedVersion.onOrAfter(Version.V_8_0_0)) {
throw new MapperParsingException("Error parsing [null_value] on field [" + name() + "]: " + e.getMessage(), e); throw new MapperParsingException("Error parsing [null_value] on field [" + name() + "]: " + e.getMessage(), e);
} else { } else {
DEPRECATION_LOGGER.deprecate(DeprecationCategory.MAPPINGS, "date_mapper_null_field", DEPRECATION_LOGGER.critical(DeprecationCategory.MAPPINGS, "date_mapper_null_field",
"Error parsing [" + nullValue.getValue() "Error parsing [" + nullValue.getValue()
+ "] as date in [null_value] on field [" + name() + "]); [null_value] will be ignored"); + "] as date in [null_value] on field [" + name() + "]); [null_value] will be ignored");
return null; return null;

View file

@ -1130,7 +1130,7 @@ public abstract class FieldMapper extends Mapper implements Cloneable {
} }
if (Objects.equals("boost", propName)) { if (Objects.equals("boost", propName)) {
if (parserContext.indexVersionCreated().before(Version.V_8_0_0)) { if (parserContext.indexVersionCreated().before(Version.V_8_0_0)) {
deprecationLogger.deprecate( deprecationLogger.critical(
DeprecationCategory.API, DeprecationCategory.API,
"boost", "boost",
"Parameter [boost] on field [{}] is deprecated and has no effect", "Parameter [boost] on field [{}] is deprecated and has no effect",
@ -1143,14 +1143,14 @@ public abstract class FieldMapper extends Mapper implements Cloneable {
} }
Parameter<?> parameter = deprecatedParamsMap.get(propName); Parameter<?> parameter = deprecatedParamsMap.get(propName);
if (parameter != null) { if (parameter != null) {
deprecationLogger.deprecate(DeprecationCategory.API, propName, "Parameter [{}] on mapper [{}] is deprecated, use [{}]", deprecationLogger.critical(DeprecationCategory.API, propName, "Parameter [{}] on mapper [{}] is deprecated, use [{}]",
propName, name, parameter.name); propName, name, parameter.name);
} else { } else {
parameter = paramsMap.get(propName); parameter = paramsMap.get(propName);
} }
if (parameter == null) { if (parameter == null) {
if (isDeprecatedParameter(propName, parserContext.indexVersionCreated())) { if (isDeprecatedParameter(propName, parserContext.indexVersionCreated())) {
deprecationLogger.deprecate(DeprecationCategory.API, propName, deprecationLogger.critical(DeprecationCategory.API, propName,
"Parameter [{}] has no effect on type [{}] and will be removed in future", propName, type); "Parameter [{}] has no effect on type [{}] and will be removed in future", propName, type);
iterator.remove(); iterator.remove();
continue; continue;
@ -1158,7 +1158,7 @@ public abstract class FieldMapper extends Mapper implements Cloneable {
if (parserContext.isFromDynamicTemplate() && parserContext.indexVersionCreated().before(Version.V_8_0_0)) { if (parserContext.isFromDynamicTemplate() && parserContext.indexVersionCreated().before(Version.V_8_0_0)) {
// The parameter is unknown, but this mapping is from a dynamic template. // The parameter is unknown, but this mapping is from a dynamic template.
// Until 7.x it was possible to use unknown parameters there, so for bwc we need to ignore it // Until 7.x it was possible to use unknown parameters there, so for bwc we need to ignore it
deprecationLogger.deprecate(DeprecationCategory.API, propName, deprecationLogger.critical(DeprecationCategory.API, propName,
"Parameter [{}] is used in a dynamic template mapping and has no effect on type [{}]. " "Parameter [{}] is used in a dynamic template mapping and has no effect on type [{}]. "
+ "Usage will result in an error in future major versions and should be removed.", + "Usage will result in an error in future major versions and should be removed.",
propName, propName,
@ -1172,7 +1172,7 @@ public abstract class FieldMapper extends Mapper implements Cloneable {
); );
} }
if (parameter.deprecated) { if (parameter.deprecated) {
deprecationLogger.deprecate(DeprecationCategory.API, propName, deprecationLogger.critical(DeprecationCategory.API, propName,
"Parameter [{}] is deprecated and will be removed in a future version", "Parameter [{}] is deprecated and will be removed in a future version",
propName); propName);
} }

View file

@ -89,7 +89,7 @@ public class FieldNamesFieldMapper extends MetadataFieldMapper {
throw new MapperParsingException("The `enabled` setting for the `_field_names` field has been deprecated and " throw new MapperParsingException("The `enabled` setting for the `_field_names` field has been deprecated and "
+ "removed. Please remove it from your mappings and templates."); + "removed. Please remove it from your mappings and templates.");
} else { } else {
deprecationLogger.deprecate(DeprecationCategory.TEMPLATES, deprecationLogger.critical(DeprecationCategory.TEMPLATES,
"field_names_enabled_parameter", ENABLED_DEPRECATION_MESSAGE); "field_names_enabled_parameter", ENABLED_DEPRECATION_MESSAGE);
} }
} }
@ -143,7 +143,7 @@ public class FieldNamesFieldMapper extends MetadataFieldMapper {
if (isEnabled() == false) { if (isEnabled() == false) {
throw new IllegalStateException("Cannot run [exists] queries if the [_field_names] field is disabled"); throw new IllegalStateException("Cannot run [exists] queries if the [_field_names] field is disabled");
} }
deprecationLogger.deprecate(DeprecationCategory.MAPPINGS, "terms_query_on_field_names", deprecationLogger.critical(DeprecationCategory.MAPPINGS, "terms_query_on_field_names",
"terms query on the _field_names field is deprecated and will be removed, use exists query instead"); "terms query on the _field_names field is deprecated and will be removed, use exists query instead");
return super.termQuery(value, context); return super.termQuery(value, context);
} }

View file

@ -91,7 +91,7 @@ public class GeoShapeFieldMapper extends AbstractShapeGeometryFieldMapper<Geomet
@Override @Override
public GeoShapeFieldMapper build(MapperBuilderContext context) { public GeoShapeFieldMapper build(MapperBuilderContext context) {
if (multiFieldsBuilder.hasMultiFields()) { if (multiFieldsBuilder.hasMultiFields()) {
DEPRECATION_LOGGER.deprecate( DEPRECATION_LOGGER.critical(
DeprecationCategory.MAPPINGS, DeprecationCategory.MAPPINGS,
"geo_shape_multifields", "geo_shape_multifields",
"Adding multifields to [geo_shape] mappers has no effect and will be forbidden in future" "Adding multifields to [geo_shape] mappers has no effect and will be forbidden in future"

View file

@ -154,7 +154,7 @@ public class IdFieldMapper extends MetadataFieldMapper {
IndexFieldDataCache cache, IndexFieldDataCache cache,
CircuitBreakerService breakerService CircuitBreakerService breakerService
) { ) {
deprecationLogger.deprecate(DeprecationCategory.AGGREGATIONS, "id_field_data", ID_FIELD_DATA_DEPRECATION_MESSAGE); deprecationLogger.critical(DeprecationCategory.AGGREGATIONS, "id_field_data", ID_FIELD_DATA_DEPRECATION_MESSAGE);
final IndexFieldData<?> fieldData = fieldDataBuilder.build(cache, final IndexFieldData<?> fieldData = fieldDataBuilder.build(cache,
breakerService); breakerService);
return new IndexFieldData<>() { return new IndexFieldData<>() {

View file

@ -120,7 +120,7 @@ public class IpFieldMapper extends FieldMapper {
if (indexCreatedVersion.onOrAfter(Version.V_8_0_0)) { if (indexCreatedVersion.onOrAfter(Version.V_8_0_0)) {
throw new MapperParsingException("Error parsing [null_value] on field [" + name() + "]: " + e.getMessage(), e); throw new MapperParsingException("Error parsing [null_value] on field [" + name() + "]: " + e.getMessage(), e);
} else { } else {
DEPRECATION_LOGGER.deprecate(DeprecationCategory.MAPPINGS, "ip_mapper_null_field", "Error parsing [" + DEPRECATION_LOGGER.critical(DeprecationCategory.MAPPINGS, "ip_mapper_null_field", "Error parsing [" +
nullValue.getValue() + "] as IP in [null_value] on field [" + name() + "]); [null_value] will be ignored"); nullValue.getValue() + "] as IP in [null_value] on field [" + name() + "]); [null_value] will be ignored");
return null; return null;
} }

View file

@ -155,7 +155,7 @@ public class ObjectMapper extends Mapper implements Cloneable {
} }
return true; return true;
} else if (fieldName.equals("include_in_all")) { } else if (fieldName.equals("include_in_all")) {
deprecationLogger.deprecate(DeprecationCategory.MAPPINGS, "include_in_all", deprecationLogger.critical(DeprecationCategory.MAPPINGS, "include_in_all",
"[include_in_all] is deprecated, the _all field have been removed in this version"); "[include_in_all] is deprecated, the _all field have been removed in this version");
return true; return true;
} }

View file

@ -443,7 +443,7 @@ public class RootObjectMapper extends ObjectMapper {
if (failInvalidDynamicTemplates) { if (failInvalidDynamicTemplates) {
throw new IllegalArgumentException(message, lastError); throw new IllegalArgumentException(message, lastError);
} else { } else {
DEPRECATION_LOGGER.deprecate(DeprecationCategory.TEMPLATES, "invalid_dynamic_template", DEPRECATION_LOGGER.critical(DeprecationCategory.TEMPLATES, "invalid_dynamic_template",
"{}, last error: [{}]", message, lastError.getMessage()); "{}, last error: [{}]", message, lastError.getMessage());
} }
} }

View file

@ -92,7 +92,7 @@ public class TypeParsers {
// For indices created prior to 8.0, we only emit a deprecation warning and do not fail type parsing. This is to // For indices created prior to 8.0, we only emit a deprecation warning and do not fail type parsing. This is to
// maintain the backwards-compatibility guarantee that we can always load indexes from the previous major version. // maintain the backwards-compatibility guarantee that we can always load indexes from the previous major version.
if (parserContext.indexVersionCreated().before(Version.V_8_0_0)) { if (parserContext.indexVersionCreated().before(Version.V_8_0_0)) {
deprecationLogger.deprecate( deprecationLogger.critical(
DeprecationCategory.INDICES, DeprecationCategory.INDICES,
"multifield_within_multifield", "multifield_within_multifield",
"At least one multi-field, [" "At least one multi-field, ["

View file

@ -522,7 +522,7 @@ public abstract class AbstractGeometryQueryBuilder<QB extends AbstractGeometryQu
params.id = parser.text(); params.id = parser.text();
} else if (parser.getRestApiVersion() == RestApiVersion.V_7 && } else if (parser.getRestApiVersion() == RestApiVersion.V_7 &&
SHAPE_TYPE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { SHAPE_TYPE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
deprecationLogger.compatibleApiWarning("geo_share_query_with_types", TYPES_DEPRECATION_MESSAGE); deprecationLogger.compatibleCritical("geo_share_query_with_types", TYPES_DEPRECATION_MESSAGE);
} else if (SHAPE_INDEX_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { } else if (SHAPE_INDEX_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
params.index = parser.text(); params.index = parser.text();
} else if (SHAPE_PATH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { } else if (SHAPE_PATH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {

View file

@ -58,7 +58,7 @@ public class CommonTermsQueryBuilder extends AbstractQueryBuilder<CommonTermsQue
} }
public static CommonTermsQueryBuilder fromXContent(XContentParser parser) throws IOException { public static CommonTermsQueryBuilder fromXContent(XContentParser parser) throws IOException {
deprecationLogger.compatibleApiWarning("common_term_query", COMMON_TERMS_QUERY_DEPRECATION_MSG); deprecationLogger.compatibleCritical("common_term_query", COMMON_TERMS_QUERY_DEPRECATION_MSG);
throw new ParsingException(parser.getTokenLocation(), COMMON_TERMS_QUERY_DEPRECATION_MSG); throw new ParsingException(parser.getTokenLocation(), COMMON_TERMS_QUERY_DEPRECATION_MSG);
} }

View file

@ -356,7 +356,7 @@ public class MoreLikeThisQueryBuilder extends AbstractQueryBuilder<MoreLikeThisQ
item.index = parser.text(); item.index = parser.text();
} else if (parser.getRestApiVersion() == RestApiVersion.V_7 && } else if (parser.getRestApiVersion() == RestApiVersion.V_7 &&
TYPE.match(currentFieldName, parser.getDeprecationHandler())) { TYPE.match(currentFieldName, parser.getDeprecationHandler())) {
deprecationLogger.compatibleApiWarning("more_like_this_query_with_types", TYPES_DEPRECATION_MESSAGE); deprecationLogger.compatibleCritical("more_like_this_query_with_types", TYPES_DEPRECATION_MESSAGE);
} else if (ID.match(currentFieldName, parser.getDeprecationHandler())) { } else if (ID.match(currentFieldName, parser.getDeprecationHandler())) {
item.id = parser.text(); item.id = parser.text();
} else if (DOC.match(currentFieldName, parser.getDeprecationHandler())) { } else if (DOC.match(currentFieldName, parser.getDeprecationHandler())) {

View file

@ -82,7 +82,7 @@ public class TypeQueryV7Builder extends AbstractQueryBuilder<TypeQueryV7Builder>
} }
public static TypeQueryV7Builder fromXContent(XContentParser parser) throws IOException { public static TypeQueryV7Builder fromXContent(XContentParser parser) throws IOException {
deprecationLogger.compatibleApiWarning("type_query", TYPES_DEPRECATION_MESSAGE); deprecationLogger.compatibleCritical("type_query", TYPES_DEPRECATION_MESSAGE);
throw new ParsingException(parser.getTokenLocation(), TYPES_DEPRECATION_MESSAGE); throw new ParsingException(parser.getTokenLocation(), TYPES_DEPRECATION_MESSAGE);
} }

View file

@ -147,7 +147,7 @@ public class RandomScoreFunctionBuilder extends ScoreFunctionBuilder<RandomScore
} else { } else {
String fieldName; String fieldName;
if (field == null) { if (field == null) {
deprecationLogger.deprecate(DeprecationCategory.QUERIES, "seed_requires_field", deprecationLogger.critical(DeprecationCategory.QUERIES, "seed_requires_field",
"As of version 7.0 Elasticsearch will require that a [field] parameter is provided when a [seed] is set"); "As of version 7.0 Elasticsearch will require that a [field] parameter is provided when a [seed] is set");
fieldName = IdFieldMapper.NAME; fieldName = IdFieldMapper.NAME;
} else { } else {

View file

@ -104,7 +104,7 @@ final class SimilarityProviders {
throw new IllegalArgumentException("Basic model [" + basicModel + "] isn't supported anymore, " + throw new IllegalArgumentException("Basic model [" + basicModel + "] isn't supported anymore, " +
"please use another model."); "please use another model.");
} else { } else {
deprecationLogger.deprecate(DeprecationCategory.INDICES, basicModel + "_similarity_model_replaced", "Basic model [" deprecationLogger.critical(DeprecationCategory.INDICES, basicModel + "_similarity_model_replaced", "Basic model ["
+ basicModel + "] isn't supported anymore and has arbitrarily been replaced with [" + replacement + "]."); + basicModel + "] isn't supported anymore and has arbitrarily been replaced with [" + replacement + "].");
model = BASIC_MODELS.get(replacement); model = BASIC_MODELS.get(replacement);
assert model != null; assert model != null;
@ -135,7 +135,7 @@ final class SimilarityProviders {
throw new IllegalArgumentException("After effect [" + afterEffect + throw new IllegalArgumentException("After effect [" + afterEffect +
"] isn't supported anymore, please use another effect."); "] isn't supported anymore, please use another effect.");
} else { } else {
deprecationLogger.deprecate(DeprecationCategory.INDICES, afterEffect + "_after_effect_replaced", "After effect [" deprecationLogger.critical(DeprecationCategory.INDICES, afterEffect + "_after_effect_replaced", "After effect ["
+ afterEffect + "] isn't supported anymore and has arbitrarily been replaced with [" + replacement + "]."); + afterEffect + "] isn't supported anymore and has arbitrarily been replaced with [" + replacement + "].");
effect = AFTER_EFFECTS.get(replacement); effect = AFTER_EFFECTS.get(replacement);
assert effect != null; assert effect != null;
@ -225,7 +225,7 @@ final class SimilarityProviders {
if (version.onOrAfter(Version.V_7_0_0)) { if (version.onOrAfter(Version.V_7_0_0)) {
throw new IllegalArgumentException("Unknown settings for similarity of type [" + type + "]: " + unknownSettings); throw new IllegalArgumentException("Unknown settings for similarity of type [" + type + "]: " + unknownSettings);
} else { } else {
deprecationLogger.deprecate(DeprecationCategory.INDICES, "unknown_similarity_setting", deprecationLogger.critical(DeprecationCategory.INDICES, "unknown_similarity_setting",
"Unknown settings for similarity of type [" + type + "]: " + unknownSettings); "Unknown settings for similarity of type [" + type + "]: " + unknownSettings);
} }
} }

View file

@ -111,7 +111,7 @@ public final class SimilarityService {
defaultSimilarity = (providers.get("default") != null) ? providers.get("default").get() defaultSimilarity = (providers.get("default") != null) ? providers.get("default").get()
: providers.get(SimilarityService.DEFAULT_SIMILARITY).get(); : providers.get(SimilarityService.DEFAULT_SIMILARITY).get();
if (providers.get("base") != null) { if (providers.get("base") != null) {
deprecationLogger.deprecate(DeprecationCategory.QUERIES, "base_similarity_ignored", deprecationLogger.critical(DeprecationCategory.QUERIES, "base_similarity_ignored",
"The [base] similarity is ignored since query normalization and coords have been removed"); "The [base] similarity is ignored since query normalization and coords have been removed");
} }
} }

View file

@ -114,7 +114,7 @@ public final class AnalysisModule {
@Override @Override
public TokenFilterFactory get(IndexSettings indexSettings, Environment environment, String name, Settings settings) { public TokenFilterFactory get(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
if (indexSettings.getIndexVersionCreated().before(Version.V_7_0_0)) { if (indexSettings.getIndexVersionCreated().before(Version.V_7_0_0)) {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "standard_deprecation", deprecationLogger.critical(DeprecationCategory.ANALYSIS, "standard_deprecation",
"The [standard] token filter name is deprecated and will be removed in a future version."); "The [standard] token filter name is deprecated and will be removed in a future version.");
} else { } else {
throw new IllegalArgumentException("The [standard] token filter has been removed."); throw new IllegalArgumentException("The [standard] token filter has been removed.");
@ -175,7 +175,7 @@ public final class AnalysisModule {
// in certain circumstances to create a new index referencing the standard token filter // in certain circumstances to create a new index referencing the standard token filter
// until version 7_5_2 // until version 7_5_2
if (version.before(Version.V_7_6_0)) { if (version.before(Version.V_7_6_0)) {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "standard_deprecation", deprecationLogger.critical(DeprecationCategory.ANALYSIS, "standard_deprecation",
"The [standard] token filter is deprecated and will be removed in a future version."); "The [standard] token filter is deprecated and will be removed in a future version.");
} else { } else {
throw new IllegalArgumentException("The [standard] token filter has been removed."); throw new IllegalArgumentException("The [standard] token filter has been removed.");

View file

@ -38,7 +38,7 @@ public class ConditionalProcessor extends AbstractProcessor implements WrappingP
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class);
private static final Map<String, Function<Object, Object>> FUNCTIONS = Map.of( private static final Map<String, Function<Object, Object>> FUNCTIONS = Map.of(
"_type", value -> { "_type", value -> {
deprecationLogger.deprecate(DeprecationCategory.INDICES, "conditional-processor__type", deprecationLogger.critical(DeprecationCategory.INDICES, "conditional-processor__type",
"[types removal] Looking up doc types [_type] in scripts is deprecated."); "[types removal] Looking up doc types [_type] in scripts is deprecated.");
return value; return value;
}); });

View file

@ -306,7 +306,7 @@ public class Node implements Closeable {
logger.info("JVM home [{}], using bundled JDK [{}]", System.getProperty("java.home"), jvmInfo.getUsingBundledJdk()); logger.info("JVM home [{}], using bundled JDK [{}]", System.getProperty("java.home"), jvmInfo.getUsingBundledJdk());
} else { } else {
logger.info("JVM home [{}]", System.getProperty("java.home")); logger.info("JVM home [{}]", System.getProperty("java.home"));
deprecationLogger.deprecate( deprecationLogger.critical(
DeprecationCategory.OTHER, DeprecationCategory.OTHER,
"no-jdk", "no-jdk",
"no-jdk distributions that do not bundle a JDK are deprecated and will be removed in a future release"); "no-jdk distributions that do not bundle a JDK are deprecated and will be removed in a future release");
@ -320,7 +320,7 @@ public class Node implements Closeable {
if (Environment.PATH_SHARED_DATA_SETTING.exists(tmpSettings)) { if (Environment.PATH_SHARED_DATA_SETTING.exists(tmpSettings)) {
// NOTE: this must be done with an explicit check here because the deprecation property on a path setting will // NOTE: this must be done with an explicit check here because the deprecation property on a path setting will
// cause ES to fail to start since logging is not yet initialized on first read of the setting // cause ES to fail to start since logging is not yet initialized on first read of the setting
deprecationLogger.deprecate( deprecationLogger.critical(
DeprecationCategory.SETTINGS, DeprecationCategory.SETTINGS,
"shared-data-path", "shared-data-path",
"setting [path.shared_data] is deprecated and will be removed in a future release" "setting [path.shared_data] is deprecated and will be removed in a future release"

View file

@ -59,9 +59,9 @@ public class DeprecationRestHandler implements RestHandler {
@Override @Override
public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception { public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception {
if (compatibleVersionWarning == false) { if (compatibleVersionWarning == false) {
deprecationLogger.deprecate(DeprecationCategory.API, deprecationKey, deprecationMessage); deprecationLogger.critical(DeprecationCategory.API, deprecationKey, deprecationMessage);
} else { } else {
deprecationLogger.compatibleApiWarning(deprecationKey, deprecationMessage); deprecationLogger.compatibleCritical(deprecationKey, deprecationMessage);
} }
handler.handleRequest(request, channel, client); handler.handleRequest(request, channel, client);

View file

@ -77,7 +77,7 @@ public class RestNodesStatsAction extends BaseRestHandler {
@Override @Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
if(request.getRestApiVersion() == RestApiVersion.V_7 && request.hasParam("types")){ if(request.getRestApiVersion() == RestApiVersion.V_7 && request.hasParam("types")){
deprecationLogger.compatibleApiWarning("nodes_stats_types", TYPES_DEPRECATION_MESSAGE); deprecationLogger.compatibleCritical("nodes_stats_types", TYPES_DEPRECATION_MESSAGE);
request.param("types"); request.param("types");
} }

View file

@ -49,7 +49,7 @@ public class RestCloseIndexAction extends BaseRestHandler {
closeIndexRequest.indicesOptions(IndicesOptions.fromRequest(request, closeIndexRequest.indicesOptions())); closeIndexRequest.indicesOptions(IndicesOptions.fromRequest(request, closeIndexRequest.indicesOptions()));
String waitForActiveShards = request.param("wait_for_active_shards"); String waitForActiveShards = request.param("wait_for_active_shards");
if ("index-setting".equalsIgnoreCase(waitForActiveShards)) { if ("index-setting".equalsIgnoreCase(waitForActiveShards)) {
deprecationLogger.deprecate(DeprecationCategory.SETTINGS, "close-index-wait_for_active_shards-index-setting", deprecationLogger.critical(DeprecationCategory.SETTINGS, "close-index-wait_for_active_shards-index-setting",
"?wait_for_active_shards=index-setting is now the default behaviour; the 'index-setting' value for this parameter " + "?wait_for_active_shards=index-setting is now the default behaviour; the 'index-setting' value for this parameter " +
"should no longer be used since it will become unsupported in version " + (Version.V_7_0_0.major + 2)); "should no longer be used since it will become unsupported in version " + (Version.V_7_0_0.major + 2));
// TODO in v9: // TODO in v9:

View file

@ -62,7 +62,7 @@ public class RestCreateIndexAction extends BaseRestHandler {
CreateIndexRequest createIndexRequest = new CreateIndexRequest(request.param("index")); CreateIndexRequest createIndexRequest = new CreateIndexRequest(request.param("index"));
if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) { if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) {
request.param(INCLUDE_TYPE_NAME_PARAMETER);// just consume, it is always replaced with _doc request.param(INCLUDE_TYPE_NAME_PARAMETER);// just consume, it is always replaced with _doc
deprecationLogger.compatibleApiWarning("create_index_with_types", TYPES_DEPRECATION_MESSAGE); deprecationLogger.compatibleCritical("create_index_with_types", TYPES_DEPRECATION_MESSAGE);
} }
if (request.hasContent()) { if (request.hasContent()) {

View file

@ -67,7 +67,7 @@ public class RestGetFieldMappingAction extends BaseRestHandler {
if (request.getRestApiVersion() == RestApiVersion.V_7) { if (request.getRestApiVersion() == RestApiVersion.V_7) {
if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) { if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) {
deprecationLogger.compatibleApiWarning("get_field_mapping_with_types", INCLUDE_TYPE_DEPRECATION_MESSAGE); deprecationLogger.compatibleCritical("get_field_mapping_with_types", INCLUDE_TYPE_DEPRECATION_MESSAGE);
} }
boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, DEFAULT_INCLUDE_TYPE_NAME_POLICY); boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, DEFAULT_INCLUDE_TYPE_NAME_POLICY);
final String[] types = request.paramAsStringArrayOrEmptyIfAll("type"); final String[] types = request.paramAsStringArrayOrEmptyIfAll("type");
@ -77,7 +77,7 @@ public class RestGetFieldMappingAction extends BaseRestHandler {
if (request.hasParam("local")) { if (request.hasParam("local")) {
request.param("local"); request.param("local");
deprecationLogger.compatibleApiWarning( deprecationLogger.compatibleCritical(
"get_field_mapping_local", "get_field_mapping_local",
"Use [local] in get field mapping requests is deprecated. " + "The parameter will be removed in the next major version" "Use [local] in get field mapping requests is deprecated. " + "The parameter will be removed in the next major version"
); );

View file

@ -57,7 +57,7 @@ public class RestGetIndexTemplateAction extends BaseRestHandler {
@Override @Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
if (request.getRestApiVersion() == RestApiVersion.V_7 && request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) { if (request.getRestApiVersion() == RestApiVersion.V_7 && request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) {
deprecationLogger.compatibleApiWarning("get_index_template_include_type_name", TYPES_DEPRECATION_MESSAGE); deprecationLogger.compatibleCritical("get_index_template_include_type_name", TYPES_DEPRECATION_MESSAGE);
} }
final String[] names = Strings.splitStringByCommaToArray(request.param("name")); final String[] names = Strings.splitStringByCommaToArray(request.param("name"));

View file

@ -59,7 +59,7 @@ public class RestGetIndicesAction extends BaseRestHandler {
// starting with 7.0 we don't include types by default in the response to GET requests // starting with 7.0 we don't include types by default in the response to GET requests
if (request.getRestApiVersion() == RestApiVersion.V_7 && if (request.getRestApiVersion() == RestApiVersion.V_7 &&
request.hasParam(INCLUDE_TYPE_NAME_PARAMETER) && request.method().equals(GET)) { request.hasParam(INCLUDE_TYPE_NAME_PARAMETER) && request.method().equals(GET)) {
deprecationLogger.compatibleApiWarning("get_indices_with_types", TYPES_DEPRECATION_MESSAGE); deprecationLogger.compatibleCritical("get_indices_with_types", TYPES_DEPRECATION_MESSAGE);
} }
String[] indices = Strings.splitStringByCommaToArray(request.param("index")); String[] indices = Strings.splitStringByCommaToArray(request.param("index"));

View file

@ -70,7 +70,7 @@ public class RestGetMappingAction extends BaseRestHandler {
if (request.getRestApiVersion() == RestApiVersion.V_7) { if (request.getRestApiVersion() == RestApiVersion.V_7) {
if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) { if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) {
request.param(INCLUDE_TYPE_NAME_PARAMETER); request.param(INCLUDE_TYPE_NAME_PARAMETER);
deprecationLogger.compatibleApiWarning("get_mapping_with_types", INCLUDE_TYPE_DEPRECATION_MSG); deprecationLogger.compatibleCritical("get_mapping_with_types", INCLUDE_TYPE_DEPRECATION_MSG);
} }
final String[] types = request.paramAsStringArrayOrEmptyIfAll("type"); final String[] types = request.paramAsStringArrayOrEmptyIfAll("type");
if (request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, DEFAULT_INCLUDE_TYPE_NAME_POLICY) == false && types.length > 0) { if (request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, DEFAULT_INCLUDE_TYPE_NAME_POLICY) == false && types.length > 0) {
@ -78,7 +78,7 @@ public class RestGetMappingAction extends BaseRestHandler {
" include_type_name is set to true."); " include_type_name is set to true.");
} }
if (request.method().equals(HEAD)) { if (request.method().equals(HEAD)) {
deprecationLogger.compatibleApiWarning("get_mapping_types_removal", deprecationLogger.compatibleCritical("get_mapping_types_removal",
"Type exists requests are deprecated, as types have been deprecated."); "Type exists requests are deprecated, as types have been deprecated.");
} }
} }

View file

@ -71,7 +71,7 @@ public class RestIndicesStatsAction extends BaseRestHandler {
@Override @Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
if(request.getRestApiVersion() == RestApiVersion.V_7 && request.hasParam("types")){ if(request.getRestApiVersion() == RestApiVersion.V_7 && request.hasParam("types")){
deprecationLogger.compatibleApiWarning("indices_stats_types", TYPES_DEPRECATION_MESSAGE); deprecationLogger.compatibleCritical("indices_stats_types", TYPES_DEPRECATION_MESSAGE);
request.param("types"); request.param("types");
} }

View file

@ -55,7 +55,7 @@ public class RestPutIndexTemplateAction extends BaseRestHandler {
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
PutIndexTemplateRequest putRequest = new PutIndexTemplateRequest(request.param("name")); PutIndexTemplateRequest putRequest = new PutIndexTemplateRequest(request.param("name"));
if (request.getRestApiVersion() == RestApiVersion.V_7 && request.hasParam("template")) { if (request.getRestApiVersion() == RestApiVersion.V_7 && request.hasParam("template")) {
deprecationLogger.compatibleApiWarning("template_parameter_deprecation", deprecationLogger.compatibleCritical("template_parameter_deprecation",
"Deprecated parameter [template] used, replaced by [index_patterns]"); "Deprecated parameter [template] used, replaced by [index_patterns]");
putRequest.patterns(List.of(request.param("template"))); putRequest.patterns(List.of(request.param("template")));
} else { } else {
@ -70,7 +70,7 @@ public class RestPutIndexTemplateAction extends BaseRestHandler {
request.getXContentType()).v2(); request.getXContentType()).v2();
if(request.getRestApiVersion() == RestApiVersion.V_7) { if(request.getRestApiVersion() == RestApiVersion.V_7) {
if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER) ) { if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER) ) {
deprecationLogger.compatibleApiWarning("put_index_template_with_types", TYPES_DEPRECATION_MESSAGE); deprecationLogger.compatibleCritical("put_index_template_with_types", TYPES_DEPRECATION_MESSAGE);
} }
boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, DEFAULT_INCLUDE_TYPE_NAME_POLICY); boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, DEFAULT_INCLUDE_TYPE_NAME_POLICY);
if(includeTypeName) { if(includeTypeName) {
@ -82,7 +82,7 @@ public class RestPutIndexTemplateAction extends BaseRestHandler {
sourceAsMap = RestCreateIndexAction.prepareMappings(sourceAsMap); sourceAsMap = RestCreateIndexAction.prepareMappings(sourceAsMap);
} }
if (request.getRestApiVersion() == RestApiVersion.V_7 && sourceAsMap.containsKey("template")) { if (request.getRestApiVersion() == RestApiVersion.V_7 && sourceAsMap.containsKey("template")) {
deprecationLogger.compatibleApiWarning("template_field_deprecation", deprecationLogger.compatibleCritical("template_field_deprecation",
"Deprecated field [template] used, replaced by [index_patterns]"); "Deprecated field [template] used, replaced by [index_patterns]");
putRequest.patterns(List.of((String) sourceAsMap.remove("template"))); putRequest.patterns(List.of((String) sourceAsMap.remove("template")));
} }

View file

@ -70,7 +70,7 @@ public class RestPutMappingAction extends BaseRestHandler {
final boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, final boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER,
DEFAULT_INCLUDE_TYPE_NAME_POLICY); DEFAULT_INCLUDE_TYPE_NAME_POLICY);
if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) { if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) {
deprecationLogger.compatibleApiWarning("put_mapping_with_types", TYPES_DEPRECATION_MESSAGE); deprecationLogger.compatibleCritical("put_mapping_with_types", TYPES_DEPRECATION_MESSAGE);
} }
final String type = request.param("type"); final String type = request.param("type");
if (includeTypeName == false && if (includeTypeName == false &&

View file

@ -39,7 +39,7 @@ public abstract class RestResizeHandler extends BaseRestHandler {
@Override @Override
public final RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { public final RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
if (request.getRestApiVersion() == RestApiVersion.V_7 && request.hasParam("copy_settings")) { if (request.getRestApiVersion() == RestApiVersion.V_7 && request.hasParam("copy_settings")) {
deprecationLogger.compatibleApiWarning("copy_settings", "parameter [copy_settings] is deprecated and will be removed in 8.0.0"); deprecationLogger.compatibleCritical("copy_settings", "parameter [copy_settings] is deprecated and will be removed in 8.0.0");
final String rawCopySettings = request.param("copy_settings"); final String rawCopySettings = request.param("copy_settings");
final boolean copySettings = Booleans.parseBoolean(rawCopySettings); final boolean copySettings = Booleans.parseBoolean(rawCopySettings);

View file

@ -57,7 +57,7 @@ public class RestRolloverIndexAction extends BaseRestHandler {
boolean includeTypeName = false; boolean includeTypeName = false;
if (request.getRestApiVersion() == RestApiVersion.V_7) { if (request.getRestApiVersion() == RestApiVersion.V_7) {
if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) { if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) {
deprecationLogger.compatibleApiWarning("index_rollover_with_types", TYPES_DEPRECATION_MESSAGE); deprecationLogger.compatibleCritical("index_rollover_with_types", TYPES_DEPRECATION_MESSAGE);
} }
includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, DEFAULT_INCLUDE_TYPE_NAME_POLICY); includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, DEFAULT_INCLUDE_TYPE_NAME_POLICY);
} }

View file

@ -59,7 +59,7 @@ public class RestValidateQueryAction extends BaseRestHandler {
@Override @Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
if (request.getRestApiVersion() == RestApiVersion.V_7 && request.hasParam("type")) { if (request.getRestApiVersion() == RestApiVersion.V_7 && request.hasParam("type")) {
deprecationLogger.compatibleApiWarning("validate_query_with_types", TYPES_DEPRECATION_MESSAGE); deprecationLogger.compatibleCritical("validate_query_with_types", TYPES_DEPRECATION_MESSAGE);
request.param("type"); request.param("type");
} }

View file

@ -64,7 +64,7 @@ public class RestGetSourceAction extends BaseRestHandler {
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
if (request.getRestApiVersion() == RestApiVersion.V_7 && request.hasParam("type")) { if (request.getRestApiVersion() == RestApiVersion.V_7 && request.hasParam("type")) {
request.param("type"); // consume and ignore the type request.param("type"); // consume and ignore the type
deprecationLogger.compatibleApiWarning("get_source_with_types", TYPES_DEPRECATION_MESSAGE); deprecationLogger.compatibleCritical("get_source_with_types", TYPES_DEPRECATION_MESSAGE);
} }
final GetRequest getRequest = new GetRequest(request.param("index"), request.param("id")); final GetRequest getRequest = new GetRequest(request.param("index"), request.param("id"));

View file

@ -53,7 +53,7 @@ public class RestMultiTermVectorsAction extends BaseRestHandler {
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
if (request.getRestApiVersion() == RestApiVersion.V_7 && request.hasParam("type")) { if (request.getRestApiVersion() == RestApiVersion.V_7 && request.hasParam("type")) {
request.param("type"); request.param("type");
deprecationLogger.compatibleApiWarning(DeprecationRestHandler.DEPRECATED_ROUTE_KEY, TYPES_DEPRECATION_MESSAGE); deprecationLogger.compatibleCritical(DeprecationRestHandler.DEPRECATED_ROUTE_KEY, TYPES_DEPRECATION_MESSAGE);
} }
MultiTermVectorsRequest multiTermVectorsRequest = new MultiTermVectorsRequest(); MultiTermVectorsRequest multiTermVectorsRequest = new MultiTermVectorsRequest();
TermVectorsRequest template = new TermVectorsRequest() TermVectorsRequest template = new TermVectorsRequest()

View file

@ -59,7 +59,7 @@ public class RestCountAction extends BaseRestHandler {
@Override @Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
if (request.getRestApiVersion() == RestApiVersion.V_7 && request.hasParam("type")) { if (request.getRestApiVersion() == RestApiVersion.V_7 && request.hasParam("type")) {
deprecationLogger.compatibleApiWarning("count_with_types", TYPES_DEPRECATION_MESSAGE); deprecationLogger.compatibleCritical("count_with_types", TYPES_DEPRECATION_MESSAGE);
request.param("type"); request.param("type");
} }
SearchRequest countRequest = new SearchRequest(Strings.splitStringByCommaToArray(request.param("index"))); SearchRequest countRequest = new SearchRequest(Strings.splitStringByCommaToArray(request.param("index")));

View file

@ -131,7 +131,7 @@ public class RestSearchAction extends BaseRestHandler {
IntConsumer setSize) throws IOException { IntConsumer setSize) throws IOException {
if (request.getRestApiVersion() == RestApiVersion.V_7 && request.hasParam("type")) { if (request.getRestApiVersion() == RestApiVersion.V_7 && request.hasParam("type")) {
request.param("type"); request.param("type");
deprecationLogger.compatibleApiWarning("search_with_types", TYPES_DEPRECATION_MESSAGE); deprecationLogger.compatibleCritical("search_with_types", TYPES_DEPRECATION_MESSAGE);
} }
if (searchRequest.source() == null) { if (searchRequest.source() == null) {
@ -209,7 +209,7 @@ public class RestSearchAction extends BaseRestHandler {
int size = request.paramAsInt("size", SearchService.DEFAULT_SIZE); int size = request.paramAsInt("size", SearchService.DEFAULT_SIZE);
if (request.getRestApiVersion() == RestApiVersion.V_7 && size == -1) { if (request.getRestApiVersion() == RestApiVersion.V_7 && size == -1) {
// we treat -1 as not-set, but deprecate it to be able to later remove this funny extra treatment // we treat -1 as not-set, but deprecate it to be able to later remove this funny extra treatment
deprecationLogger.compatibleApiWarning( deprecationLogger.compatibleCritical(
"search-api-size-1", "search-api-size-1",
"Using search size of -1 is deprecated and will be removed in future versions. " "Using search size of -1 is deprecated and will be removed in future versions. "
+ "Instead, don't use the `size` parameter if you don't want to set it explicitly." + "Instead, don't use the `size` parameter if you don't want to set it explicitly."

View file

@ -24,13 +24,13 @@ abstract class AbstractSortScript extends DocBasedScript implements ScorerAware
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class);
private static final Map<String, Function<Object, Object>> PARAMS_FUNCTIONS = Map.of( private static final Map<String, Function<Object, Object>> PARAMS_FUNCTIONS = Map.of(
"doc", value -> { "doc", value -> {
deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "sort-script_doc", deprecationLogger.critical(DeprecationCategory.SCRIPTING, "sort-script_doc",
"Accessing variable [doc] via [params.doc] from within an sort-script " "Accessing variable [doc] via [params.doc] from within an sort-script "
+ "is deprecated in favor of directly accessing [doc]."); + "is deprecated in favor of directly accessing [doc].");
return value; return value;
}, },
"_doc", value -> { "_doc", value -> {
deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "sort-script__doc", deprecationLogger.critical(DeprecationCategory.SCRIPTING, "sort-script__doc",
"Accessing variable [doc] via [params._doc] from within an sort-script " "Accessing variable [doc] via [params._doc] from within an sort-script "
+ "is deprecated in favor of directly accessing [doc]."); + "is deprecated in favor of directly accessing [doc].");
return value; return value;

View file

@ -30,13 +30,13 @@ public abstract class AggregationScript extends DocBasedScript implements Scorer
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class);
private static final Map<String, Function<Object, Object>> PARAMS_FUNCTIONS = Map.of( private static final Map<String, Function<Object, Object>> PARAMS_FUNCTIONS = Map.of(
"doc", value -> { "doc", value -> {
deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "aggregation-script_doc", deprecationLogger.critical(DeprecationCategory.SCRIPTING, "aggregation-script_doc",
"Accessing variable [doc] via [params.doc] from within an aggregation-script " "Accessing variable [doc] via [params.doc] from within an aggregation-script "
+ "is deprecated in favor of directly accessing [doc]."); + "is deprecated in favor of directly accessing [doc].");
return value; return value;
}, },
"_doc", value -> { "_doc", value -> {
deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "aggregation-script__doc", deprecationLogger.critical(DeprecationCategory.SCRIPTING, "aggregation-script__doc",
"Accessing variable [doc] via [params._doc] from within an aggregation-script " "Accessing variable [doc] via [params._doc] from within an aggregation-script "
+ "is deprecated in favor of directly accessing [doc]."); + "is deprecated in favor of directly accessing [doc].");
return value; return value;

View file

@ -29,13 +29,13 @@ public abstract class FieldScript extends DocBasedScript {
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class);
private static final Map<String, Function<Object, Object>> PARAMS_FUNCTIONS = Map.of( private static final Map<String, Function<Object, Object>> PARAMS_FUNCTIONS = Map.of(
"doc", value -> { "doc", value -> {
deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "field-script_doc", deprecationLogger.critical(DeprecationCategory.SCRIPTING, "field-script_doc",
"Accessing variable [doc] via [params.doc] from within an field-script " "Accessing variable [doc] via [params.doc] from within an field-script "
+ "is deprecated in favor of directly accessing [doc]."); + "is deprecated in favor of directly accessing [doc].");
return value; return value;
}, },
"_doc", value -> { "_doc", value -> {
deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "field-script__doc", deprecationLogger.critical(DeprecationCategory.SCRIPTING, "field-script__doc",
"Accessing variable [doc] via [params._doc] from within an field-script " "Accessing variable [doc] via [params._doc] from within an field-script "
+ "is deprecated in favor of directly accessing [doc]."); + "is deprecated in favor of directly accessing [doc].");
return value; return value;

View file

@ -58,7 +58,7 @@ public class JodaCompatibleZonedDateTime
@SuppressLoggerChecks(reason = "safely delegates to logger") @SuppressLoggerChecks(reason = "safely delegates to logger")
@Override @Override
public Void run() { public Void run() {
deprecationLogger.deprecate(category, key, message, params); deprecationLogger.critical(category, key, message, params);
return null; return null;
} }
}); });

View file

@ -53,13 +53,13 @@ public abstract class ScoreScript extends DocBasedScript {
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class);
private static final Map<String, Function<Object, Object>> PARAMS_FUNCTIONS = Map.of( private static final Map<String, Function<Object, Object>> PARAMS_FUNCTIONS = Map.of(
"doc", value -> { "doc", value -> {
deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "score-script_doc", deprecationLogger.critical(DeprecationCategory.SCRIPTING, "score-script_doc",
"Accessing variable [doc] via [params.doc] from within an score-script " "Accessing variable [doc] via [params.doc] from within an score-script "
+ "is deprecated in favor of directly accessing [doc]."); + "is deprecated in favor of directly accessing [doc].");
return value; return value;
}, },
"_doc", value -> { "_doc", value -> {
deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "score-script__doc", deprecationLogger.critical(DeprecationCategory.SCRIPTING, "score-script__doc",
"Accessing variable [doc] via [params._doc] from within an score-script " "Accessing variable [doc] via [params._doc] from within an score-script "
+ "is deprecated in favor of directly accessing [doc]."); + "is deprecated in favor of directly accessing [doc].");
return value; return value;

View file

@ -208,13 +208,13 @@ public final class ScriptMetadata implements Metadata.Custom, Writeable, ToXCont
if (source.getSource().isEmpty()) { if (source.getSource().isEmpty()) {
if (source.getLang().equals(Script.DEFAULT_TEMPLATE_LANG)) { if (source.getLang().equals(Script.DEFAULT_TEMPLATE_LANG)) {
deprecationLogger.deprecate( deprecationLogger.critical(
DeprecationCategory.TEMPLATES, DeprecationCategory.TEMPLATES,
"empty_templates", "empty_templates",
"empty templates should no longer be used" "empty templates should no longer be used"
); );
} else { } else {
deprecationLogger.deprecate( deprecationLogger.critical(
DeprecationCategory.TEMPLATES, DeprecationCategory.TEMPLATES,
"empty_scripts", "empty_scripts",
"empty scripts should no longer be used" "empty scripts should no longer be used"

View file

@ -57,18 +57,18 @@ public class ScriptedMetricAggContexts {
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class);
private static final Map<String, Function<Object, Object>> PARAMS_FUNCTIONS = Map.of( private static final Map<String, Function<Object, Object>> PARAMS_FUNCTIONS = Map.of(
"doc", value -> { "doc", value -> {
deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "map-script_doc", deprecationLogger.critical(DeprecationCategory.SCRIPTING, "map-script_doc",
"Accessing variable [doc] via [params.doc] from within an scripted metric agg map script " "Accessing variable [doc] via [params.doc] from within an scripted metric agg map script "
+ "is deprecated in favor of directly accessing [doc]."); + "is deprecated in favor of directly accessing [doc].");
return value; return value;
}, },
"_doc", value -> { "_doc", value -> {
deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "map-script__doc", deprecationLogger.critical(DeprecationCategory.SCRIPTING, "map-script__doc",
"Accessing variable [doc] via [params._doc] from within an scripted metric agg map script " "Accessing variable [doc] via [params._doc] from within an scripted metric agg map script "
+ "is deprecated in favor of directly accessing [doc]."); + "is deprecated in favor of directly accessing [doc].");
return value; return value;
}, "_agg", value -> { }, "_agg", value -> {
deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "map-script__agg", deprecationLogger.critical(DeprecationCategory.SCRIPTING, "map-script__agg",
"Accessing variable [_agg] via [params._agg] from within a scripted metric agg map script " "Accessing variable [_agg] via [params._agg] from within a scripted metric agg map script "
+ "is deprecated in favor of using [state]."); + "is deprecated in favor of using [state].");
return value; return value;

View file

@ -134,10 +134,10 @@ public class StoredScriptSource extends AbstractDiffable<StoredScriptSource> imp
if (source == null) { if (source == null) {
if (ignoreEmpty || Script.DEFAULT_TEMPLATE_LANG.equals(lang)) { if (ignoreEmpty || Script.DEFAULT_TEMPLATE_LANG.equals(lang)) {
if (Script.DEFAULT_TEMPLATE_LANG.equals(lang)) { if (Script.DEFAULT_TEMPLATE_LANG.equals(lang)) {
deprecationLogger.deprecate(DeprecationCategory.TEMPLATES, "empty_templates", deprecationLogger.critical(DeprecationCategory.TEMPLATES, "empty_templates",
"empty templates should no longer be used"); "empty templates should no longer be used");
} else { } else {
deprecationLogger.deprecate(DeprecationCategory.TEMPLATES, "empty_scripts", deprecationLogger.critical(DeprecationCategory.TEMPLATES, "empty_scripts",
"empty scripts should no longer be used"); "empty scripts should no longer be used");
} }
} else { } else {
@ -146,10 +146,10 @@ public class StoredScriptSource extends AbstractDiffable<StoredScriptSource> imp
} else if (source.isEmpty()) { } else if (source.isEmpty()) {
if (ignoreEmpty || Script.DEFAULT_TEMPLATE_LANG.equals(lang)) { if (ignoreEmpty || Script.DEFAULT_TEMPLATE_LANG.equals(lang)) {
if (Script.DEFAULT_TEMPLATE_LANG.equals(lang)) { if (Script.DEFAULT_TEMPLATE_LANG.equals(lang)) {
deprecationLogger.deprecate(DeprecationCategory.TEMPLATES, "empty_templates", deprecationLogger.critical(DeprecationCategory.TEMPLATES, "empty_templates",
"empty templates should no longer be used"); "empty templates should no longer be used");
} else { } else {
deprecationLogger.deprecate(DeprecationCategory.TEMPLATES, "empty_scripts", deprecationLogger.critical(DeprecationCategory.TEMPLATES, "empty_scripts",
"empty scripts should no longer be used"); "empty scripts should no longer be used");
} }
} else { } else {
@ -250,7 +250,7 @@ public class StoredScriptSource extends AbstractDiffable<StoredScriptSource> imp
token = parser.nextToken(); token = parser.nextToken();
if (token == Token.END_OBJECT) { if (token == Token.END_OBJECT) {
deprecationLogger.deprecate(DeprecationCategory.TEMPLATES, "empty_templates", "empty templates should no longer be used"); deprecationLogger.critical(DeprecationCategory.TEMPLATES, "empty_templates", "empty templates should no longer be used");
return new StoredScriptSource(Script.DEFAULT_TEMPLATE_LANG, "", Collections.emptyMap()); return new StoredScriptSource(Script.DEFAULT_TEMPLATE_LANG, "", Collections.emptyMap());
} }

View file

@ -29,13 +29,13 @@ public abstract class TermsSetQueryScript {
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class);
private static final Map<String, Function<Object, Object>> PARAMS_FUNCTIONS = Map.of( private static final Map<String, Function<Object, Object>> PARAMS_FUNCTIONS = Map.of(
"doc", value -> { "doc", value -> {
deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "terms-set-query-script_doc", deprecationLogger.critical(DeprecationCategory.SCRIPTING, "terms-set-query-script_doc",
"Accessing variable [doc] via [params.doc] from within an terms-set-query-script " "Accessing variable [doc] via [params.doc] from within an terms-set-query-script "
+ "is deprecated in favor of directly accessing [doc]."); + "is deprecated in favor of directly accessing [doc].");
return value; return value;
}, },
"_doc", value -> { "_doc", value -> {
deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "terms-set-query-script__doc", deprecationLogger.critical(DeprecationCategory.SCRIPTING, "terms-set-query-script__doc",
"Accessing variable [doc] via [params._doc] from within an terms-set-query-script " "Accessing variable [doc] via [params._doc] from within an terms-set-query-script "
+ "is deprecated in favor of directly accessing [doc]."); + "is deprecated in favor of directly accessing [doc].");
return value; return value;

View file

@ -577,7 +577,7 @@ public abstract class InternalOrder extends BucketOrder {
} }
// _term and _time order deprecated in 6.0; replaced by _key // _term and _time order deprecated in 6.0; replaced by _key
if (parser.getRestApiVersion() == RestApiVersion.V_7 && ("_term".equals(orderKey) || "_time".equals(orderKey))) { if (parser.getRestApiVersion() == RestApiVersion.V_7 && ("_term".equals(orderKey) || "_time".equals(orderKey))) {
deprecationLogger.compatibleApiWarning( deprecationLogger.compatibleCritical(
"_term_and_time_key_removal", "_term_and_time_key_removal",
"Deprecated aggregation order key [{}] used, replaced by [_key]", "Deprecated aggregation order key [{}] used, replaced by [_key]",
orderKey orderKey

View file

@ -51,7 +51,7 @@ public final class AutoDateHistogramAggregatorFactory extends ValuesSourceAggreg
CardinalityUpperBound cardinality, CardinalityUpperBound cardinality,
Map<String, Object> metadata) -> { Map<String, Object> metadata) -> {
DEPRECATION_LOGGER.deprecate( DEPRECATION_LOGGER.critical(
DeprecationCategory.AGGREGATIONS, DeprecationCategory.AGGREGATIONS,
"auto-date-histogram-boolean", "auto-date-histogram-boolean",
"Running AutoIntervalDateHistogram aggregations on [boolean] fields is deprecated" "Running AutoIntervalDateHistogram aggregations on [boolean] fields is deprecated"

View file

@ -56,7 +56,7 @@ public final class DateHistogramAggregatorFactory extends ValuesSourceAggregator
parent, parent,
cardinality, cardinality,
metadata) -> { metadata) -> {
DEPRECATION_LOGGER.deprecate( DEPRECATION_LOGGER.critical(
DeprecationCategory.AGGREGATIONS, DeprecationCategory.AGGREGATIONS,
"date-histogram-boolean", "date-histogram-boolean",
"Running DateHistogram aggregations on [boolean] fields is deprecated" "Running DateHistogram aggregations on [boolean] fields is deprecated"

View file

@ -104,7 +104,7 @@ public class DateIntervalWrapper implements ToXContentFragment, Writeable {
but immediately adapt it into either fixed or calendar interval. but immediately adapt it into either fixed or calendar interval.
*/ */
parser.declareField((wrapper, interval) -> { parser.declareField((wrapper, interval) -> {
DEPRECATION_LOGGER.deprecate(DeprecationCategory.AGGREGATIONS, "date-interval-getter", DEPRECATION_TEXT); DEPRECATION_LOGGER.critical(DeprecationCategory.AGGREGATIONS, "date-interval-getter", DEPRECATION_TEXT);
if (interval instanceof Long) { if (interval instanceof Long) {
wrapper.fixedInterval(new DateHistogramInterval(interval + "ms")); wrapper.fixedInterval(new DateHistogramInterval(interval + "ms"));
} else { } else {

View file

@ -71,7 +71,7 @@ public class DateRangeAggregationBuilder extends AbstractRangeBuilder<DateRangeA
Aggregator parent, Aggregator parent,
CardinalityUpperBound cardinality, CardinalityUpperBound cardinality,
Map<String, Object> metadata) -> { Map<String, Object> metadata) -> {
DEPRECATION_LOGGER.deprecate( DEPRECATION_LOGGER.critical(
DeprecationCategory.AGGREGATIONS, DeprecationCategory.AGGREGATIONS,
"Range-boolean", "Range-boolean",
"Running Range or DateRange aggregations on [boolean] fields is deprecated" "Running Range or DateRange aggregations on [boolean] fields is deprecated"

View file

@ -372,7 +372,7 @@ public class SignificantTermsAggregatorFactory extends ValuesSourceAggregatorFac
if ("global_ordinals".equals(value)) { if ("global_ordinals".equals(value)) {
return GLOBAL_ORDINALS; return GLOBAL_ORDINALS;
} else if ("global_ordinals_hash".equals(value)) { } else if ("global_ordinals_hash".equals(value)) {
deprecationLogger.deprecate( deprecationLogger.critical(
DeprecationCategory.AGGREGATIONS, DeprecationCategory.AGGREGATIONS,
"global_ordinals_hash", "global_ordinals_hash",
"global_ordinals_hash is deprecated. Please use [global_ordinals] instead." "global_ordinals_hash is deprecated. Please use [global_ordinals] instead."

View file

@ -1124,7 +1124,7 @@ public final class SearchSourceBuilder implements Writeable, ToXContentObject, R
int parsedSize = parser.intValue(); int parsedSize = parser.intValue();
if (parser.getRestApiVersion() == RestApiVersion.V_7 && parsedSize == -1) { if (parser.getRestApiVersion() == RestApiVersion.V_7 && parsedSize == -1) {
// we treat -1 as not-set, but deprecate it to be able to later remove this funny extra treatment // we treat -1 as not-set, but deprecate it to be able to later remove this funny extra treatment
deprecationLogger.compatibleApiWarning( deprecationLogger.compatibleCritical(
"search-api-size-1", "search-api-size-1",
"Using search size of -1 is deprecated and will be removed in future versions. " "Using search size of -1 is deprecated and will be removed in future versions. "
+ "Instead, don't use the `size` parameter if you don't want to set it explicitly." + "Instead, don't use the `size` parameter if you don't want to set it explicitly."
@ -1180,7 +1180,7 @@ public final class SearchSourceBuilder implements Writeable, ToXContentObject, R
} }
} else if (parser.getRestApiVersion() == RestApiVersion.V_7 && } else if (parser.getRestApiVersion() == RestApiVersion.V_7 &&
INDICES_BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { INDICES_BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
deprecationLogger.compatibleApiWarning("indices_boost_object_format", deprecationLogger.compatibleCritical("indices_boost_object_format",
"Object format in indices_boost is deprecated, please use array format instead"); "Object format in indices_boost is deprecated, please use array format instead");
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {

View file

@ -64,7 +64,7 @@ public final class FieldAndFormat implements Writeable, ToXContentObject {
} else { } else {
String text = p.text(); String text = p.text();
if (text.equals(USE_DEFAULT_FORMAT)) { if (text.equals(USE_DEFAULT_FORMAT)) {
DEPRECATION_LOGGER.compatibleApiWarning("explicit_default_format", DEPRECATION_LOGGER.compatibleCritical("explicit_default_format",
"[" + USE_DEFAULT_FORMAT + "] is a special format that was only used to " + "[" + USE_DEFAULT_FORMAT + "] is a special format that was only used to " +
"ease the transition to 7.x. It has become the default and shouldn't be set explicitly anymore."); "ease the transition to 7.x. It has become the default and shouldn't be set explicitly anymore.");
return null; return null;

View file

@ -411,7 +411,7 @@ public class GeoDistanceSortBuilder extends SortBuilder<GeoDistanceSortBuilder>
} else if (token == XContentParser.Token.START_OBJECT) { } else if (token == XContentParser.Token.START_OBJECT) {
if (parser.getRestApiVersion() == RestApiVersion.V_7 && if (parser.getRestApiVersion() == RestApiVersion.V_7 &&
NESTED_FILTER_FIELD.match(currentName, parser.getDeprecationHandler())) { NESTED_FILTER_FIELD.match(currentName, parser.getDeprecationHandler())) {
deprecationLogger.compatibleApiWarning("nested_filter", deprecationLogger.compatibleCritical("nested_filter",
"[nested_filter] has been removed in favour of the [nested] parameter"); "[nested_filter] has been removed in favour of the [nested] parameter");
throw new ParsingException( throw new ParsingException(
parser.getTokenLocation(), parser.getTokenLocation(),
@ -436,7 +436,7 @@ public class GeoDistanceSortBuilder extends SortBuilder<GeoDistanceSortBuilder>
} else if (token.isValue()) { } else if (token.isValue()) {
if (parser.getRestApiVersion() == RestApiVersion.V_7 && if (parser.getRestApiVersion() == RestApiVersion.V_7 &&
NESTED_PATH_FIELD.match(currentName, parser.getDeprecationHandler())) { NESTED_PATH_FIELD.match(currentName, parser.getDeprecationHandler())) {
deprecationLogger.compatibleApiWarning("nested_path", deprecationLogger.compatibleCritical("nested_path",
"[nested_path] has been removed in favour of the [nested] parameter"); "[nested_path] has been removed in favour of the [nested] parameter");
throw new ParsingException( throw new ParsingException(
parser.getTokenLocation(), parser.getTokenLocation(),

View file

@ -280,7 +280,7 @@ public class GeoContextMapping extends ContextMapping<GeoQueryContext> {
MappedFieldType mappedFieldType = fieldResolver.apply(fieldName); MappedFieldType mappedFieldType = fieldResolver.apply(fieldName);
if (mappedFieldType == null) { if (mappedFieldType == null) {
if (indexVersionCreated.before(Version.V_7_0_0)) { if (indexVersionCreated.before(Version.V_7_0_0)) {
deprecationLogger.deprecate(DeprecationCategory.MAPPINGS, "geo_context_mapping", deprecationLogger.critical(DeprecationCategory.MAPPINGS, "geo_context_mapping",
"field [{}] referenced in context [{}] is not defined in the mapping", fieldName, name); "field [{}] referenced in context [{}] is not defined in the mapping", fieldName, name);
} else { } else {
throw new ElasticsearchParseException( throw new ElasticsearchParseException(
@ -288,7 +288,7 @@ public class GeoContextMapping extends ContextMapping<GeoQueryContext> {
} }
} else if (GeoPointFieldMapper.CONTENT_TYPE.equals(mappedFieldType.typeName()) == false) { } else if (GeoPointFieldMapper.CONTENT_TYPE.equals(mappedFieldType.typeName()) == false) {
if (indexVersionCreated.before(Version.V_7_0_0)) { if (indexVersionCreated.before(Version.V_7_0_0)) {
deprecationLogger.deprecate(DeprecationCategory.MAPPINGS, "geo_context_mapping", deprecationLogger.critical(DeprecationCategory.MAPPINGS, "geo_context_mapping",
"field [{}] referenced in context [{}] must be mapped to geo_point, found [{}]", "field [{}] referenced in context [{}] must be mapped to geo_point, found [{}]",
fieldName, name, mappedFieldType.typeName()); fieldName, name, mappedFieldType.typeName());
} else { } else {

View file

@ -401,7 +401,7 @@ public class RestoreService implements ClusterStateApplier {
// log a deprecation warning if the any of the indexes to delete were included in the request and the snapshot // log a deprecation warning if the any of the indexes to delete were included in the request and the snapshot
// is from a version that should have feature states // is from a version that should have feature states
if (snapshotInfo.version().onOrAfter(Version.V_7_12_0) && explicitlyRequestedSystemIndices.isEmpty() == false) { if (snapshotInfo.version().onOrAfter(Version.V_7_12_0) && explicitlyRequestedSystemIndices.isEmpty() == false) {
deprecationLogger.deprecate( deprecationLogger.critical(
DeprecationCategory.API, DeprecationCategory.API,
"restore-system-index-from-snapshot", "restore-system-index-from-snapshot",
"Restoring system indices by name is deprecated. Use feature states instead. System indices: " "Restoring system indices by name is deprecated. Use feature states instead. System indices: "

View file

@ -91,7 +91,7 @@ public class TransportInfo implements ReportingService.Info {
if (InetAddresses.isInetAddress(hostString) == false) { if (InetAddresses.isInetAddress(hostString) == false) {
publishAddressString = hostString + '/' + publishAddress.toString(); publishAddressString = hostString + '/' + publishAddress.toString();
if (cnameInPublishAddressProperty) { if (cnameInPublishAddressProperty) {
deprecationLogger.deprecate(DeprecationCategory.SETTINGS, "cname_in_publish_address", deprecationLogger.critical(DeprecationCategory.SETTINGS, "cname_in_publish_address",
"es.transport.cname_in_publish_address system property is deprecated and no longer affects " + propertyName + "es.transport.cname_in_publish_address system property is deprecated and no longer affects " + propertyName +
" formatting. Remove this property to get rid of this deprecation warning."); " formatting. Remove this property to get rid of this deprecation warning.");
} }

View file

@ -107,14 +107,14 @@ public class TransportAnalyzeActionTests extends ESTestCase {
@Override @Override
public TokenStream create(TokenStream tokenStream) { public TokenStream create(TokenStream tokenStream) {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "deprecated_token_filter_create", deprecationLogger.critical(DeprecationCategory.ANALYSIS, "deprecated_token_filter_create",
"Using deprecated token filter [deprecated]"); "Using deprecated token filter [deprecated]");
return tokenStream; return tokenStream;
} }
@Override @Override
public TokenStream normalize(TokenStream tokenStream) { public TokenStream normalize(TokenStream tokenStream) {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "deprecated_token_filter_normalize", deprecationLogger.critical(DeprecationCategory.ANALYSIS, "deprecated_token_filter_normalize",
"Using deprecated token filter [deprecated]"); "Using deprecated token filter [deprecated]");
return tokenStream; return tokenStream;
} }

View file

@ -314,7 +314,7 @@ public class AnalysisRegistryTests extends ESTestCase {
@Override @Override
public TokenStream create(TokenStream tokenStream) { public TokenStream create(TokenStream tokenStream) {
if (indexSettings.getIndexVersionCreated().equals(Version.CURRENT)) { if (indexSettings.getIndexVersionCreated().equals(Version.CURRENT)) {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "deprecated_token_filter", deprecationLogger.critical(DeprecationCategory.ANALYSIS, "deprecated_token_filter",
"Using deprecated token filter [deprecated]"); "Using deprecated token filter [deprecated]");
} }
return tokenStream; return tokenStream;
@ -343,7 +343,7 @@ public class AnalysisRegistryTests extends ESTestCase {
@Override @Override
public TokenStream create(TokenStream tokenStream) { public TokenStream create(TokenStream tokenStream) {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "unused_token_filter", deprecationLogger.critical(DeprecationCategory.ANALYSIS, "unused_token_filter",
"Using deprecated token filter [unused]"); "Using deprecated token filter [unused]");
return tokenStream; return tokenStream;
} }
@ -357,7 +357,7 @@ public class AnalysisRegistryTests extends ESTestCase {
@Override @Override
public TokenStream create(TokenStream tokenStream) { public TokenStream create(TokenStream tokenStream) {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "deprecated_normalizer", deprecationLogger.critical(DeprecationCategory.ANALYSIS, "deprecated_normalizer",
"Using deprecated token filter [deprecated_normalizer]"); "Using deprecated token filter [deprecated_normalizer]");
return tokenStream; return tokenStream;
} }

View file

@ -76,10 +76,10 @@ public class DeprecationRestHandlerTests extends ESTestCase {
// log, then forward // log, then forward
if (compatibleVersionWarning) { if (compatibleVersionWarning) {
inOrder.verify(deprecationLogger) inOrder.verify(deprecationLogger)
.compatibleApiWarning("deprecated_route_GET_/some/path", deprecationMessage); .compatibleCritical("deprecated_route_GET_/some/path", deprecationMessage);
} else { } else {
inOrder.verify(deprecationLogger) inOrder.verify(deprecationLogger)
.deprecate(DeprecationCategory.API, "deprecated_route_GET_/some/path", deprecationMessage); .critical(DeprecationCategory.API, "deprecated_route_GET_/some/path", deprecationMessage);
} }
inOrder.verify(handler).handleRequest(request, channel, client); inOrder.verify(handler).handleRequest(request, channel, client);

View file

@ -253,7 +253,7 @@ public class ESLoggerUsageTests extends ESTestCase {
public void checkDeprecationLogger() { public void checkDeprecationLogger() {
DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(ESLoggerUsageTests.class); DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(ESLoggerUsageTests.class);
deprecationLogger.deprecate(DeprecationCategory.OTHER, "key","message {}", 123); deprecationLogger.critical(DeprecationCategory.OTHER, "key","message {}", 123);
} }
} }

View file

@ -55,7 +55,7 @@ public class DeprecatedQueryBuilder extends AbstractQueryBuilder<DeprecatedQuery
@Override @Override
protected Query doToQuery(SearchExecutionContext context) { protected Query doToQuery(SearchExecutionContext context) {
deprecationLogger.deprecate(DeprecationCategory.QUERIES, "to_query", "[deprecated] query"); deprecationLogger.critical(DeprecationCategory.QUERIES, "to_query", "[deprecated] query");
return new MatchAllDocsQuery(); return new MatchAllDocsQuery();
} }

View file

@ -73,7 +73,7 @@ public class RestGetLicenseAction extends BaseRestHandler {
// In 7.x, there was an opt-in flag to show "enterprise" licenses. In 8.0 the flag is deprecated and can only be true // In 7.x, there was an opt-in flag to show "enterprise" licenses. In 8.0 the flag is deprecated and can only be true
// TODO Remove this from 9.0 // TODO Remove this from 9.0
if (request.hasParam("accept_enterprise")) { if (request.hasParam("accept_enterprise")) {
deprecationLogger.deprecate(DeprecationCategory.API, "get_license_accept_enterprise", deprecationLogger.critical(DeprecationCategory.API, "get_license_accept_enterprise",
"Including [accept_enterprise] in get license requests is deprecated." + "Including [accept_enterprise] in get license requests is deprecated." +
" The parameter will be removed in the next major version"); " The parameter will be removed in the next major version");
if (request.paramAsBoolean("accept_enterprise", true) == false if (request.paramAsBoolean("accept_enterprise", true) == false

View file

@ -354,7 +354,7 @@ public class XPackPlugin extends XPackClientPlugin
if (Files.exists(config) == false) { if (Files.exists(config) == false) {
Path legacyConfig = env.configFile().resolve("x-pack").resolve(name); Path legacyConfig = env.configFile().resolve("x-pack").resolve(name);
if (Files.exists(legacyConfig)) { if (Files.exists(legacyConfig)) {
deprecationLogger.deprecate(DeprecationCategory.OTHER, "config_file_path", deprecationLogger.critical(DeprecationCategory.OTHER, "config_file_path",
"Config file [" + name + "] is in a deprecated location. Move from " + "Config file [" + name + "] is in a deprecated location. Move from " +
legacyConfig.toString() + " to " + config.toString()); legacyConfig.toString() + " to " + config.toString());
return legacyConfig; return legacyConfig;

View file

@ -49,7 +49,7 @@ public class RestXPackInfoAction extends BaseRestHandler {
// In 7.x, there was an opt-in flag to show "enterprise" licenses. In 8.0 the flag is deprecated and can only be true // In 7.x, there was an opt-in flag to show "enterprise" licenses. In 8.0 the flag is deprecated and can only be true
// TODO Remove this from 9.0 // TODO Remove this from 9.0
if (request.hasParam("accept_enterprise")) { if (request.hasParam("accept_enterprise")) {
deprecationLogger.deprecate(DeprecationCategory.API, "get_license_accept_enterprise", deprecationLogger.critical(DeprecationCategory.API, "get_license_accept_enterprise",
"Including [accept_enterprise] in get license requests is deprecated." + "Including [accept_enterprise] in get license requests is deprecated." +
" The parameter will be removed in the next major version"); " The parameter will be removed in the next major version");
if (request.paramAsBoolean("accept_enterprise", true) == false if (request.paramAsBoolean("accept_enterprise", true) == false

Some files were not shown because too many files have changed in this diff Show more