[7.16] Drop non-setting deprecations down to warning level (#80374)

Complementary to #79665 this change
will reduce the deprecation logging level to WARN for (most) all non-settings that
continue to exist in 8.0+.
This commit is contained in:
Jake Landis 2021-11-10 13:07:56 -06:00 committed by GitHub
parent f736645266
commit 6358afb0cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
99 changed files with 191 additions and 127 deletions

View file

@ -248,7 +248,7 @@ public class CommonAnalysisPlugin extends Plugin implements AnalysisPlugin, Scri
filters.put("dutch_stem", DutchStemTokenFilterFactory::new); filters.put("dutch_stem", DutchStemTokenFilterFactory::new);
filters.put("edge_ngram", EdgeNGramTokenFilterFactory::new); filters.put("edge_ngram", EdgeNGramTokenFilterFactory::new);
filters.put("edgeNGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> { filters.put("edgeNGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.ANALYSIS, DeprecationCategory.ANALYSIS,
"edgeNGram_deprecation", "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. "
@ -276,7 +276,7 @@ public class CommonAnalysisPlugin extends Plugin implements AnalysisPlugin, Scri
filters.put("multiplexer", MultiplexerTokenFilterFactory::new); filters.put("multiplexer", MultiplexerTokenFilterFactory::new);
filters.put("ngram", NGramTokenFilterFactory::new); filters.put("ngram", NGramTokenFilterFactory::new);
filters.put("nGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> { filters.put("nGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.ANALYSIS, DeprecationCategory.ANALYSIS,
"nGram_deprecation", "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. "
@ -330,7 +330,7 @@ public class CommonAnalysisPlugin extends Plugin implements AnalysisPlugin, Scri
tokenizers.put("thai", ThaiTokenizerFactory::new); tokenizers.put("thai", ThaiTokenizerFactory::new);
tokenizers.put("nGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> { tokenizers.put("nGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> {
if (indexSettings.getIndexVersionCreated().onOrAfter(org.elasticsearch.Version.V_7_6_0)) { if (indexSettings.getIndexVersionCreated().onOrAfter(org.elasticsearch.Version.V_7_6_0)) {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.ANALYSIS, DeprecationCategory.ANALYSIS,
"nGram_tokenizer_deprecation", "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. "
@ -342,7 +342,7 @@ public class CommonAnalysisPlugin extends Plugin implements AnalysisPlugin, Scri
tokenizers.put("ngram", NGramTokenizerFactory::new); tokenizers.put("ngram", NGramTokenizerFactory::new);
tokenizers.put("edgeNGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> { tokenizers.put("edgeNGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> {
if (indexSettings.getIndexVersionCreated().onOrAfter(org.elasticsearch.Version.V_7_6_0)) { if (indexSettings.getIndexVersionCreated().onOrAfter(org.elasticsearch.Version.V_7_6_0)) {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.ANALYSIS, DeprecationCategory.ANALYSIS,
"edgeNGram_tokenizer_deprecation", "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. "
@ -645,7 +645,7 @@ public class CommonAnalysisPlugin extends Plugin implements AnalysisPlugin, Scri
// Temporary shim for aliases. TODO deprecate after they are moved // Temporary shim for aliases. TODO deprecate after they are moved
tokenizers.add(PreConfiguredTokenizer.elasticsearchVersion("nGram", (version) -> { tokenizers.add(PreConfiguredTokenizer.elasticsearchVersion("nGram", (version) -> {
if (version.onOrAfter(org.elasticsearch.Version.V_7_6_0)) { if (version.onOrAfter(org.elasticsearch.Version.V_7_6_0)) {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.ANALYSIS, DeprecationCategory.ANALYSIS,
"nGram_tokenizer_deprecation", "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. "
@ -656,7 +656,7 @@ public class CommonAnalysisPlugin extends Plugin implements AnalysisPlugin, Scri
})); }));
tokenizers.add(PreConfiguredTokenizer.elasticsearchVersion("edgeNGram", (version) -> { tokenizers.add(PreConfiguredTokenizer.elasticsearchVersion("edgeNGram", (version) -> {
if (version.onOrAfter(org.elasticsearch.Version.V_7_6_0)) { if (version.onOrAfter(org.elasticsearch.Version.V_7_6_0)) {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.ANALYSIS, DeprecationCategory.ANALYSIS,
"edgeNGram_tokenizer_deprecation", "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. "

View file

@ -46,7 +46,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.critical( DEPRECATION_LOGGER.warn(
DeprecationCategory.ANALYSIS, DeprecationCategory.ANALYSIS,
"synonym_ignore_case_option", "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. "

View file

@ -8,6 +8,7 @@
package org.elasticsearch.analysis.common; package org.elasticsearch.analysis.common;
import org.apache.logging.log4j.Level;
import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.Tokenizer;
import org.elasticsearch.Version; import org.elasticsearch.Version;
@ -193,6 +194,7 @@ public class CommonAnalysisPluginTests extends ESTestCase {
createTestAnalysis(IndexSettingsModule.newIndexSettings("index", settings), settings, commonAnalysisPlugin); createTestAnalysis(IndexSettingsModule.newIndexSettings("index", settings), settings, commonAnalysisPlugin);
assertWarnings( assertWarnings(
Level.WARN,
"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."
); );
@ -214,6 +216,7 @@ public class CommonAnalysisPluginTests extends ESTestCase {
createTestAnalysis(IndexSettingsModule.newIndexSettings("index", settings), settings, commonAnalysisPlugin); createTestAnalysis(IndexSettingsModule.newIndexSettings("index", settings), settings, commonAnalysisPlugin);
assertWarnings( assertWarnings(
Level.WARN,
"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."
); );
@ -276,6 +279,7 @@ public class CommonAnalysisPluginTests extends ESTestCase {
assertNotNull(tokenizer); assertNotNull(tokenizer);
if (expectWarning) { if (expectWarning) {
assertWarnings( assertWarnings(
Level.WARN,
"The [" "The ["
+ deprecatedName + deprecatedName
+ "] tokenizer name is deprecated and will be removed in a future version. " + "] tokenizer name is deprecated and will be removed in a future version. "
@ -302,6 +306,7 @@ public class CommonAnalysisPluginTests extends ESTestCase {
if (expectWarning) { if (expectWarning) {
assertWarnings( assertWarnings(
Level.WARN,
"The [" "The ["
+ deprecatedName + deprecatedName
+ "] tokenizer name is deprecated and will be removed in a future version. " + "] tokenizer name is deprecated and will be removed in a future version. "

View file

@ -8,6 +8,7 @@
package org.elasticsearch.analysis.common; package org.elasticsearch.analysis.common;
import org.apache.logging.log4j.Level;
import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
@ -57,7 +58,7 @@ public class CompoundAnalysisTests extends ESTestCase {
hasItems("donau", "dampf", "schiff", "donaudampfschiff", "spargel", "creme", "suppe", "spargelcremesuppe") hasItems("donau", "dampf", "schiff", "donaudampfschiff", "spargel", "creme", "suppe", "spargelcremesuppe")
); );
} }
assertWarnings("Setting [version] on analysis component [custom7] has no effect and is deprecated"); assertWarnings(Level.WARN, "Setting [version] on analysis component [custom7] has no effect and is deprecated");
} }
private List<String> analyze(Settings settings, String analyzerName, String text) throws IOException { private List<String> analyze(Settings settings, String analyzerName, String text) throws IOException {

View file

@ -8,6 +8,7 @@
package org.elasticsearch.ingest.common; package org.elasticsearch.ingest.common;
import org.apache.logging.log4j.Level;
import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.common.unit.ByteSizeUnit; import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.ByteSizeValue;
@ -84,6 +85,7 @@ public class BytesProcessorTests extends AbstractStringProcessorTestCase<Long> {
processor.execute(ingestDocument); processor.execute(ingestDocument);
assertThat(ingestDocument.getFieldValue(fieldName, expectedResultType()), equalTo(1126L)); assertThat(ingestDocument.getFieldValue(fieldName, expectedResultType()), equalTo(1126L));
assertWarnings( assertWarnings(
Level.WARN,
"Fractional bytes values are deprecated. Use non-fractional bytes values instead: [1.1kb] found for setting " + "[Ingest Field]" "Fractional bytes values are deprecated. Use non-fractional bytes values instead: [1.1kb] found for setting " + "[Ingest Field]"
); );
} }

View file

@ -68,7 +68,7 @@ public class ReindexValidator {
); );
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.critical(DeprecationCategory.API, "reindex_sort", SORT_DEPRECATED_MESSAGE); deprecationLogger.warn(DeprecationCategory.API, "reindex_sort", SORT_DEPRECATED_MESSAGE);
} }
} }

View file

@ -8,6 +8,7 @@
package org.elasticsearch.reindex; package org.elasticsearch.reindex;
import org.apache.logging.log4j.Level;
import org.elasticsearch.index.query.RangeQueryBuilder; import org.elasticsearch.index.query.RangeQueryBuilder;
import org.elasticsearch.index.reindex.ReindexAction; import org.elasticsearch.index.reindex.ReindexAction;
import org.elasticsearch.index.reindex.ReindexRequestBuilder; import org.elasticsearch.index.reindex.ReindexRequestBuilder;
@ -47,6 +48,6 @@ public class ReindexSingleNodeTests extends ESSingleNodeTestCase {
assertHitCount(client().prepareSearch("dest").setSize(0).get(), subsetSize); assertHitCount(client().prepareSearch("dest").setSize(0).get(), subsetSize);
assertHitCount(client().prepareSearch("dest").setQuery(new RangeQueryBuilder("foo").gte(0).lt(max - subsetSize)).get(), 0); assertHitCount(client().prepareSearch("dest").setQuery(new RangeQueryBuilder("foo").gte(0).lt(max - subsetSize)).get(), 0);
assertWarnings(ReindexValidator.SORT_DEPRECATED_MESSAGE); assertWarnings(Level.WARN, ReindexValidator.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.critical(DeprecationCategory.PLUGINS, "azure_discovery_plugin", "azure classic discovery plugin is deprecated."); deprecationLogger.warn(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

@ -151,7 +151,7 @@ final class Ec2ClientSettings {
return null; return null;
} else { } else {
if (key.length() == 0) { if (key.length() == 0) {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.SETTINGS, DeprecationCategory.SETTINGS,
"ec2_invalid_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",
@ -160,7 +160,7 @@ final class Ec2ClientSettings {
); );
} }
if (secret.length() == 0) { if (secret.length() == 0) {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.SETTINGS, DeprecationCategory.SETTINGS,
"ec2_invalid_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",

View file

@ -15,7 +15,7 @@ import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.auth.BasicSessionCredentials; import com.amazonaws.auth.BasicSessionCredentials;
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
import org.elasticsearch.common.logging.DeprecationLogger; import org.apache.logging.log4j.Level;
import org.elasticsearch.common.settings.MockSecureSettings; import org.elasticsearch.common.settings.MockSecureSettings;
import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
@ -73,7 +73,7 @@ public class AwsEc2ServiceImplTests extends ESTestCase {
assertSettingDeprecationsAndWarnings( assertSettingDeprecationsAndWarnings(
new Setting<?>[] {}, new Setting<?>[] {},
new DeprecationWarning( new DeprecationWarning(
DeprecationLogger.CRITICAL, Level.WARN,
"Setting [discovery.ec2.access_key] is set but " + "[discovery.ec2.secret_key] is not, which will be unsupported in future" "Setting [discovery.ec2.access_key] is set but " + "[discovery.ec2.secret_key] is not, which will be unsupported in future"
) )
); );
@ -91,7 +91,7 @@ public class AwsEc2ServiceImplTests extends ESTestCase {
assertSettingDeprecationsAndWarnings( assertSettingDeprecationsAndWarnings(
new Setting<?>[] {}, new Setting<?>[] {},
new DeprecationWarning( new DeprecationWarning(
DeprecationLogger.CRITICAL, Level.WARN,
"Setting [discovery.ec2.secret_key] is set but " + "[discovery.ec2.access_key] is not, which will be unsupported in future" "Setting [discovery.ec2.secret_key] is set but " + "[discovery.ec2.access_key] is not, which will be unsupported in future"
) )
); );

View file

@ -115,7 +115,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.critical( deprecationLogger.warn(
DeprecationCategory.OTHER, DeprecationCategory.OTHER,
Integer.toString(id), Integer.toString(id),
"This is a maybe logged deprecation message" + id "This is a maybe logged deprecation message" + id
@ -167,7 +167,7 @@ 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),
DeprecationLogger.CRITICAL, Level.WARN,
"org.elasticsearch.common.logging.DeprecationLogger.logDeprecation", "org.elasticsearch.common.logging.DeprecationLogger.logDeprecation",
"This is a maybe logged deprecation message" + i "This is a maybe logged deprecation message" + i
); );

View file

@ -227,7 +227,7 @@ public class TransportGetAliasesAction extends TransportMasterNodeReadAction<Get
} }
if (systemAliases.isEmpty() == false) { if (systemAliases.isEmpty() == false) {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.API, DeprecationCategory.API,
"open_system_alias_access", "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 "

View file

@ -899,7 +899,7 @@ public class TransportSearchAction extends HandledTransportAction<SearchRequest,
} }
} }
if (frozenIndices != null) { if (frozenIndices != null) {
DEPRECATION_LOGGER.critical( DEPRECATION_LOGGER.warn(
DeprecationCategory.INDICES, DeprecationCategory.INDICES,
"search-frozen-indices", "search-frozen-indices",
FROZEN_INDICES_DEPRECATION_MESSAGE, FROZEN_INDICES_DEPRECATION_MESSAGE,

View file

@ -220,7 +220,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 {
DEPRECATION_LOGGER.critical( DEPRECATION_LOGGER.warn(
DeprecationCategory.INDICES, DeprecationCategory.INDICES,
"index_name_starts_with_dot", "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 "

View file

@ -193,7 +193,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.critical( deprecationLogger.warn(
DeprecationCategory.PARSING, DeprecationCategory.PARSING,
"timezone", "timezone",
"Use of short timezone id " + zoneId + " is deprecated. Use " + deprecatedId + " instead" "Use of short timezone id " + zoneId + " is deprecated. Use " + deprecatedId + " instead"

View file

@ -292,7 +292,7 @@ public class ByteSizeValue implements Writeable, Comparable<ByteSizeValue>, ToXC
} catch (final NumberFormatException e) { } catch (final NumberFormatException e) {
try { try {
final double doubleValue = Double.parseDouble(s); final double doubleValue = Double.parseDouble(s);
DeprecationLoggerHolder.deprecationLogger.critical( DeprecationLoggerHolder.deprecationLogger.warn(
DeprecationCategory.PARSING, DeprecationCategory.PARSING,
"fractional_byte_values", "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 [{}]",

View file

@ -217,7 +217,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.critical( DEPRECATION_LOGGER.warn(
DeprecationCategory.MAPPINGS, DeprecationCategory.MAPPINGS,
"index-sort-aliases", "index-sort-aliases",
"Index sort for index [" "Index sort for index ["

View file

@ -73,7 +73,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.critical( DEPRECATION_LOGGER.warn(
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

@ -46,7 +46,7 @@ public class ShingleTokenFilterFactory extends AbstractTokenFilterFactory {
+ "] index level setting." + "] index level setting."
); );
} else { } else {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.ANALYSIS, DeprecationCategory.ANALYSIS,
"excessive_shingle_diff", "excessive_shingle_diff",
"Deprecated big difference between maxShingleSize and minShingleSize" "Deprecated big difference between maxShingleSize and minShingleSize"
@ -81,7 +81,7 @@ public class ShingleTokenFilterFactory extends AbstractTokenFilterFactory {
if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) {
throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms");
} else { } else {
DEPRECATION_LOGGER.critical( DEPRECATION_LOGGER.warn(
DeprecationCategory.ANALYSIS, DeprecationCategory.ANALYSIS,
"synonym_tokenfilters", "synonym_tokenfilters",
"Token filter " + name() + "] will not be usable to parse synonym after v7.0" "Token filter " + name() + "] will not be usable to parse synonym after v7.0"

View file

@ -205,7 +205,7 @@ public class CompletionFieldMapper extends FieldMapper {
private void checkCompletionContextsLimit() { private void checkCompletionContextsLimit() {
if (this.contexts.getValue() != null && this.contexts.getValue().size() > COMPLETION_CONTEXTS_LIMIT) { if (this.contexts.getValue() != null && this.contexts.getValue().size() > COMPLETION_CONTEXTS_LIMIT) {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.MAPPINGS, DeprecationCategory.MAPPINGS,
"excessive_completion_contexts", "excessive_completion_contexts",
"You have defined more than [" "You have defined more than ["

View file

@ -311,7 +311,7 @@ public final class DateFieldMapper extends FieldMapper {
try { try {
return fieldType.parse(nullValue.getValue()); return fieldType.parse(nullValue.getValue());
} catch (Exception e) { } catch (Exception e) {
DEPRECATION_LOGGER.critical( DEPRECATION_LOGGER.warn(
DeprecationCategory.MAPPINGS, DeprecationCategory.MAPPINGS,
"date_mapper_null_field", "date_mapper_null_field",
"Error parsing [" "Error parsing ["

View file

@ -141,7 +141,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.critical( deprecationLogger.warn(
DeprecationCategory.MAPPINGS, DeprecationCategory.MAPPINGS,
"terms_query_on_field_names", "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"

View file

@ -96,7 +96,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.critical( DEPRECATION_LOGGER.warn(
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

@ -151,7 +151,7 @@ public class RandomScoreFunctionBuilder extends ScoreFunctionBuilder<RandomScore
} else { } else {
String fieldName; String fieldName;
if (field == null) { if (field == null) {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.QUERIES, DeprecationCategory.QUERIES,
"seed_requires_field", "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"

View file

@ -172,7 +172,7 @@ final class SimilarityProviders {
"After effect [" + afterEffect + "] isn't supported anymore, please use another effect." "After effect [" + afterEffect + "] isn't supported anymore, please use another effect."
); );
} else { } else {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.QUERIES, DeprecationCategory.QUERIES,
afterEffect + "_after_effect_replaced", afterEffect + "_after_effect_replaced",
"After effect [" "After effect ["

View file

@ -155,7 +155,7 @@ public final class SimilarityService {
? providers.get("default").get() ? 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.critical( deprecationLogger.warn(
DeprecationCategory.QUERIES, DeprecationCategory.QUERIES,
"base_similarity_ignored", "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

@ -127,7 +127,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.critical( deprecationLogger.warn(
DeprecationCategory.ANALYSIS, DeprecationCategory.ANALYSIS,
"standard_deprecation", "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."
@ -196,7 +196,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.critical( deprecationLogger.warn(
DeprecationCategory.ANALYSIS, DeprecationCategory.ANALYSIS,
"standard_deprecation", "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."

View file

@ -351,7 +351,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.critical( deprecationLogger.warn(
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"

View file

@ -23,14 +23,14 @@ 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 = org.elasticsearch.core.Map.of("doc", value -> { private static final Map<String, Function<Object, Object>> PARAMS_FUNCTIONS = org.elasticsearch.core.Map.of("doc", value -> {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.SCRIPTING, DeprecationCategory.SCRIPTING,
"sort-script_doc", "sort-script_doc",
"Accessing variable [doc] via [params.doc] from within an sort-script " + "is deprecated in favor of directly accessing [doc]." "Accessing variable [doc] via [params.doc] from within an sort-script " + "is deprecated in favor of directly accessing [doc]."
); );
return value; return value;
}, "_doc", value -> { }, "_doc", value -> {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.SCRIPTING, DeprecationCategory.SCRIPTING,
"sort-script__doc", "sort-script__doc",
"Accessing variable [doc] via [params._doc] from within an sort-script " + "is deprecated in favor of directly accessing [doc]." "Accessing variable [doc] via [params._doc] from within an sort-script " + "is deprecated in favor of directly accessing [doc]."

View file

@ -29,7 +29,7 @@ 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 = org.elasticsearch.core.Map.of("doc", value -> { private static final Map<String, Function<Object, Object>> PARAMS_FUNCTIONS = org.elasticsearch.core.Map.of("doc", value -> {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.SCRIPTING, DeprecationCategory.SCRIPTING,
"aggregation-script_doc", "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 "
@ -37,7 +37,7 @@ public abstract class AggregationScript extends DocBasedScript implements Scorer
); );
return value; return value;
}, "_doc", value -> { }, "_doc", value -> {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.SCRIPTING, DeprecationCategory.SCRIPTING,
"aggregation-script__doc", "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 "

View file

@ -28,14 +28,14 @@ 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 = org.elasticsearch.core.Map.of("doc", value -> { private static final Map<String, Function<Object, Object>> PARAMS_FUNCTIONS = org.elasticsearch.core.Map.of("doc", value -> {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.SCRIPTING, DeprecationCategory.SCRIPTING,
"field-script_doc", "field-script_doc",
"Accessing variable [doc] via [params.doc] from within an field-script " + "is deprecated in favor of directly accessing [doc]." "Accessing variable [doc] via [params.doc] from within an field-script " + "is deprecated in favor of directly accessing [doc]."
); );
return value; return value;
}, "_doc", value -> { }, "_doc", value -> {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.SCRIPTING, DeprecationCategory.SCRIPTING,
"field-script__doc", "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 "

View file

@ -52,14 +52,14 @@ 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 = org.elasticsearch.core.Map.of("doc", value -> { private static final Map<String, Function<Object, Object>> PARAMS_FUNCTIONS = org.elasticsearch.core.Map.of("doc", value -> {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.SCRIPTING, DeprecationCategory.SCRIPTING,
"score-script_doc", "score-script_doc",
"Accessing variable [doc] via [params.doc] from within an score-script " + "is deprecated in favor of directly accessing [doc]." "Accessing variable [doc] via [params.doc] from within an score-script " + "is deprecated in favor of directly accessing [doc]."
); );
return value; return value;
}, "_doc", value -> { }, "_doc", value -> {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.SCRIPTING, DeprecationCategory.SCRIPTING,
"score-script__doc", "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 "

View file

@ -56,7 +56,7 @@ 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 = org.elasticsearch.core.Map.of("doc", value -> { private static final Map<String, Function<Object, Object>> PARAMS_FUNCTIONS = org.elasticsearch.core.Map.of("doc", value -> {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.SCRIPTING, DeprecationCategory.SCRIPTING,
"map-script_doc", "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 "
@ -64,7 +64,7 @@ public class ScriptedMetricAggContexts {
); );
return value; return value;
}, "_doc", value -> { }, "_doc", value -> {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.SCRIPTING, DeprecationCategory.SCRIPTING,
"map-script__doc", "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 "
@ -72,7 +72,7 @@ public class ScriptedMetricAggContexts {
); );
return value; return value;
}, "_agg", value -> { }, "_agg", value -> {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.SCRIPTING, DeprecationCategory.SCRIPTING,
"map-script__agg", "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 "

View file

@ -28,7 +28,7 @@ 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 = org.elasticsearch.core.Map.of("doc", value -> { private static final Map<String, Function<Object, Object>> PARAMS_FUNCTIONS = org.elasticsearch.core.Map.of("doc", value -> {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.SCRIPTING, DeprecationCategory.SCRIPTING,
"terms-set-query-script_doc", "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 "
@ -36,7 +36,7 @@ public abstract class TermsSetQueryScript {
); );
return value; return value;
}, "_doc", value -> { }, "_doc", value -> {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.SCRIPTING, DeprecationCategory.SCRIPTING,
"terms-set-query-script__doc", "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 "

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.critical( DEPRECATION_LOGGER.warn(
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.critical( DEPRECATION_LOGGER.warn(
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

@ -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.critical( DEPRECATION_LOGGER.warn(
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.critical( deprecationLogger.warn(
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

@ -282,7 +282,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.critical( deprecationLogger.warn(
DeprecationCategory.MAPPINGS, DeprecationCategory.MAPPINGS,
"geo_context_mapping", "geo_context_mapping",
"field [{}] referenced in context [{}] is not defined in the mapping", "field [{}] referenced in context [{}] is not defined in the mapping",
@ -298,7 +298,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.critical( deprecationLogger.warn(
DeprecationCategory.MAPPINGS, DeprecationCategory.MAPPINGS,
"geo_context_mapping", "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 [{}]",

View file

@ -7,6 +7,7 @@
*/ */
package org.elasticsearch.action.admin.indices; package org.elasticsearch.action.admin.indices;
import org.apache.logging.log4j.Level;
import org.apache.lucene.analysis.MockTokenFilter; import org.apache.lucene.analysis.MockTokenFilter;
import org.apache.lucene.analysis.MockTokenizer; import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
@ -108,7 +109,7 @@ public class TransportAnalyzeActionTests extends ESTestCase {
@Override @Override
public TokenStream create(TokenStream tokenStream) { public TokenStream create(TokenStream tokenStream) {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.OTHER, DeprecationCategory.OTHER,
"deprecated_token_filter_create", "deprecated_token_filter_create",
"Using deprecated token filter [deprecated]" "Using deprecated token filter [deprecated]"
@ -118,7 +119,7 @@ public class TransportAnalyzeActionTests extends ESTestCase {
@Override @Override
public TokenStream normalize(TokenStream tokenStream) { public TokenStream normalize(TokenStream tokenStream) {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.OTHER, DeprecationCategory.OTHER,
"deprecated_token_filter_normalize", "deprecated_token_filter_normalize",
"Using deprecated token filter [deprecated]" "Using deprecated token filter [deprecated]"
@ -574,7 +575,7 @@ public class TransportAnalyzeActionTests extends ESTestCase {
AnalyzeAction.Response analyze = TransportAnalyzeAction.analyze(req, registry, mockIndexService(), maxTokenCount); AnalyzeAction.Response analyze = TransportAnalyzeAction.analyze(req, registry, mockIndexService(), maxTokenCount);
assertEquals(2, analyze.getTokens().size()); assertEquals(2, analyze.getTokens().size());
assertWarnings("Using deprecated token filter [deprecated]"); assertWarnings(Level.WARN, "Using deprecated token filter [deprecated]");
// normalizer // normalizer
req = new AnalyzeAction.Request(); req = new AnalyzeAction.Request();
@ -584,6 +585,6 @@ public class TransportAnalyzeActionTests extends ESTestCase {
analyze = TransportAnalyzeAction.analyze(req, registry, mockIndexService(), maxTokenCount); analyze = TransportAnalyzeAction.analyze(req, registry, mockIndexService(), maxTokenCount);
assertEquals(1, analyze.getTokens().size()); assertEquals(1, analyze.getTokens().size());
assertWarnings("Using deprecated token filter [deprecated]"); assertWarnings(Level.WARN, "Using deprecated token filter [deprecated]");
} }
} }

View file

@ -269,6 +269,7 @@ public class TransportGetAliasesActionTests extends ESTestCase {
); );
assertThat(result.size(), equalTo(0)); assertThat(result.size(), equalTo(0));
assertWarnings( assertWarnings(
Level.WARN,
"this request accesses aliases with names reserved for system indices: [.y], but in a future major version, direct" "this request accesses aliases with names reserved for system indices: [.y], but in a future major version, direct"
+ " access to system indices and their aliases will not be allowed" + " access to system indices and their aliases will not be allowed"
); );

View file

@ -686,6 +686,7 @@ public class MetadataCreateIndexServiceTests extends ESTestCase {
// Check deprecations // Check deprecations
assertFalse(checkerService.validateDotIndex(".test2", false)); assertFalse(checkerService.validateDotIndex(".test2", false));
assertWarnings( assertWarnings(
Level.WARN,
"index name [.test2] starts with a dot '.', in the next major version, index " "index name [.test2] starts with a dot '.', in the next major version, index "
+ "names starting with a dot are reserved for hidden indices and system indices" + "names starting with a dot are reserved for hidden indices and system indices"
); );

View file

@ -8,6 +8,7 @@
package org.elasticsearch.common.time; package org.elasticsearch.common.time;
import org.apache.logging.log4j.Level;
import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.ESTestCase;
import org.joda.time.DateTimeZone; import org.joda.time.DateTimeZone;
@ -61,7 +62,7 @@ public class DateUtilsTests extends ESTestCase {
equalTo(jodaTz.getOffset(now)) equalTo(jodaTz.getOffset(now))
); );
if (DateUtils.DEPRECATED_SHORT_TIMEZONES.containsKey(jodaTz.getID())) { if (DateUtils.DEPRECATED_SHORT_TIMEZONES.containsKey(jodaTz.getID())) {
assertWarnings("Use of short timezone id " + jodaId + " is deprecated. Use " + zoneId.getId() + " instead"); assertWarnings(Level.WARN, "Use of short timezone id " + jodaId + " is deprecated. Use " + zoneId.getId() + " instead");
} }
// roundtrip does not throw either // roundtrip does not throw either
assertNotNull(DateUtils.zoneIdToDateTimeZone(zoneId)); assertNotNull(DateUtils.zoneIdToDateTimeZone(zoneId));

View file

@ -8,6 +8,7 @@
package org.elasticsearch.common.unit; package org.elasticsearch.common.unit;
import org.apache.logging.log4j.Level;
import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.io.stream.Writeable.Reader; import org.elasticsearch.common.io.stream.Writeable.Reader;
import org.elasticsearch.test.AbstractWireSerializingTestCase; import org.elasticsearch.test.AbstractWireSerializingTestCase;
@ -322,6 +323,7 @@ public class ByteSizeValueTests extends AbstractWireSerializingTestCase<ByteSize
ByteSizeValue instance = ByteSizeValue.parseBytesSizeValue(fractionalValue, "test"); ByteSizeValue instance = ByteSizeValue.parseBytesSizeValue(fractionalValue, "test");
assertEquals(fractionalValue, instance.toString()); assertEquals(fractionalValue, instance.toString());
assertWarnings( assertWarnings(
Level.WARN,
"Fractional bytes values are deprecated. Use non-fractional bytes values instead: [" "Fractional bytes values are deprecated. Use non-fractional bytes values instead: ["
+ fractionalValue + fractionalValue
+ "] found for setting [test]" + "] found for setting [test]"

View file

@ -8,6 +8,7 @@
package org.elasticsearch.index; package org.elasticsearch.index;
import org.apache.logging.log4j.Level;
import org.apache.lucene.search.Query; import org.apache.lucene.search.Query;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
@ -184,6 +185,7 @@ public class IndexSortSettingsTests extends ESTestCase {
config.buildIndexSort(field -> mft, (ft, s) -> indexFieldDataService.getForField(ft, "index", s)); config.buildIndexSort(field -> mft, (ft, s) -> indexFieldDataService.getForField(ft, "index", s));
assertWarnings( assertWarnings(
Level.WARN,
"Index sort for index [test] defined on field [field] which resolves to field [aliased]. " "Index sort for index [test] defined on field [field] which resolves to field [aliased]. "
+ "You will not be able to define an index sort over aliased fields in new indexes" + "You will not be able to define an index sort over aliased fields in new indexes"
); );

View file

@ -10,6 +10,7 @@ package org.elasticsearch.index.analysis;
import com.carrotsearch.randomizedtesting.generators.RandomPicks; import com.carrotsearch.randomizedtesting.generators.RandomPicks;
import org.apache.logging.log4j.Level;
import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockTokenFilter; import org.apache.lucene.analysis.MockTokenFilter;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
@ -353,7 +354,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.critical( deprecationLogger.warn(
DeprecationCategory.OTHER, DeprecationCategory.OTHER,
"deprecated_token_filter", "deprecated_token_filter",
"Using deprecated token filter [deprecated]" "Using deprecated token filter [deprecated]"
@ -385,7 +386,7 @@ public class AnalysisRegistryTests extends ESTestCase {
@Override @Override
public TokenStream create(TokenStream tokenStream) { public TokenStream create(TokenStream tokenStream) {
deprecationLogger.critical(DeprecationCategory.OTHER, "unused_token_filter", "Using deprecated token filter [unused]"); deprecationLogger.warn(DeprecationCategory.OTHER, "unused_token_filter", "Using deprecated token filter [unused]");
return tokenStream; return tokenStream;
} }
} }
@ -398,7 +399,7 @@ public class AnalysisRegistryTests extends ESTestCase {
@Override @Override
public TokenStream create(TokenStream tokenStream) { public TokenStream create(TokenStream tokenStream) {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.OTHER, DeprecationCategory.OTHER,
"deprecated_normalizer", "deprecated_normalizer",
"Using deprecated token filter [deprecated_normalizer]" "Using deprecated token filter [deprecated_normalizer]"
@ -432,7 +433,7 @@ public class AnalysisRegistryTests extends ESTestCase {
new AnalysisModule(TestEnvironment.newEnvironment(settings), singletonList(plugin)).getAnalysisRegistry().build(idxSettings); new AnalysisModule(TestEnvironment.newEnvironment(settings), singletonList(plugin)).getAnalysisRegistry().build(idxSettings);
// We should only get a warning from the token filter that is referenced in settings // We should only get a warning from the token filter that is referenced in settings
assertWarnings("Using deprecated token filter [deprecated]"); assertWarnings(Level.WARN, "Using deprecated token filter [deprecated]");
indexSettings = Settings.builder() indexSettings = Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.getPreviousVersion()) .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.getPreviousVersion())
@ -450,7 +451,7 @@ public class AnalysisRegistryTests extends ESTestCase {
// We should only get a warning from the normalizer, because we're on a version where 'deprecated' // We should only get a warning from the normalizer, because we're on a version where 'deprecated'
// works fine // works fine
assertWarnings("Using deprecated token filter [deprecated_normalizer]"); assertWarnings(Level.WARN, "Using deprecated token filter [deprecated_normalizer]");
indexSettings = Settings.builder() indexSettings = Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)

View file

@ -7,6 +7,7 @@
*/ */
package org.elasticsearch.index.mapper; package org.elasticsearch.index.mapper;
import org.apache.logging.log4j.Level;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.core.SimpleAnalyzer; import org.apache.lucene.analysis.core.SimpleAnalyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer;
@ -763,6 +764,7 @@ public class CompletionFieldMapperTests extends MapperTestCase {
b.endArray(); b.endArray();
})); }));
assertWarnings( assertWarnings(
Level.WARN,
"You have defined more than [10] completion contexts in the mapping for field [field]. " "You have defined more than [10] completion contexts in the mapping for field [field]. "
+ "The maximum allowed number of completion contexts in a mapping will be limited to [10] starting in version [8.0]." + "The maximum allowed number of completion contexts in a mapping will be limited to [10] starting in version [8.0]."
); );

View file

@ -8,6 +8,7 @@
package org.elasticsearch.index.mapper; package org.elasticsearch.index.mapper;
import org.apache.logging.log4j.Level;
import org.apache.lucene.index.DocValuesType; import org.apache.lucene.index.DocValuesType;
import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.IndexableField;
import org.elasticsearch.common.time.DateFormatter; import org.elasticsearch.common.time.DateFormatter;
@ -246,7 +247,7 @@ public class DateFieldMapperTests extends MapperTestCase {
public void testBadNullValue() throws IOException { public void testBadNullValue() throws IOException {
createDocumentMapper(fieldMapping(b -> b.field("type", "date").field("null_value", "foo"))); createDocumentMapper(fieldMapping(b -> b.field("type", "date").field("null_value", "foo")));
assertWarnings("Error parsing [foo] as date in [null_value] on field [field]); [null_value] will be ignored"); assertWarnings(Level.WARN, "Error parsing [foo] as date in [null_value] on field [field]); [null_value] will be ignored");
} }
public void testNullConfigValuesFail() { public void testNullConfigValuesFail() {

View file

@ -7,6 +7,7 @@
*/ */
package org.elasticsearch.index.mapper; package org.elasticsearch.index.mapper;
import org.apache.logging.log4j.Level;
import org.apache.lucene.index.Term; import org.apache.lucene.index.Term;
import org.apache.lucene.search.Query; import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.TermQuery;
@ -60,7 +61,7 @@ public class FieldNamesFieldTypeTests extends ESTestCase {
); );
Query termQuery = fieldNamesFieldType.termQuery("field_name", searchExecutionContext); Query termQuery = fieldNamesFieldType.termQuery("field_name", searchExecutionContext);
assertEquals(new TermQuery(new Term(FieldNamesFieldMapper.CONTENT_TYPE, "field_name")), termQuery); assertEquals(new TermQuery(new Term(FieldNamesFieldMapper.CONTENT_TYPE, "field_name")), termQuery);
assertWarnings("terms query on the _field_names field is deprecated and will be removed, use exists query instead"); assertWarnings(Level.WARN, "terms query on the _field_names field is deprecated and will be removed, use exists query instead");
FieldNamesFieldMapper.FieldNamesFieldType unsearchable = FieldNamesFieldMapper.FieldNamesFieldType.get(false); FieldNamesFieldMapper.FieldNamesFieldType unsearchable = FieldNamesFieldMapper.FieldNamesFieldType.get(false);
IllegalStateException e = expectThrows(IllegalStateException.class, () -> unsearchable.termQuery("field_name", null)); IllegalStateException e = expectThrows(IllegalStateException.class, () -> unsearchable.termQuery("field_name", null));

View file

@ -7,6 +7,7 @@
*/ */
package org.elasticsearch.index.mapper; package org.elasticsearch.index.mapper;
import org.apache.logging.log4j.Level;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
import org.elasticsearch.common.geo.Orientation; import org.elasticsearch.common.geo.Orientation;
import org.elasticsearch.core.List; import org.elasticsearch.core.List;
@ -210,7 +211,7 @@ public class GeoShapeFieldMapperTests extends MapperTestCase {
b.startObject("keyword").field("type", "keyword").endObject(); b.startObject("keyword").field("type", "keyword").endObject();
b.endObject(); b.endObject();
})); }));
assertWarnings("Adding multifields to [geo_shape] mappers has no effect and will be forbidden in future"); assertWarnings(Level.WARN, "Adding multifields to [geo_shape] mappers has no effect and will be forbidden in future");
} }
@Override @Override

View file

@ -8,6 +8,7 @@
package org.elasticsearch.index.query.functionscore; package org.elasticsearch.index.query.functionscore;
import org.apache.logging.log4j.Level;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
@ -56,7 +57,10 @@ public class ScoreFunctionBuilderTests extends ESTestCase {
Mockito.when(context.getFieldType(IdFieldMapper.NAME)).thenReturn(new KeywordFieldMapper.KeywordFieldType(IdFieldMapper.NAME)); Mockito.when(context.getFieldType(IdFieldMapper.NAME)).thenReturn(new KeywordFieldMapper.KeywordFieldType(IdFieldMapper.NAME));
Mockito.when(context.isFieldMapped(IdFieldMapper.NAME)).thenReturn(true); Mockito.when(context.isFieldMapped(IdFieldMapper.NAME)).thenReturn(true);
builder.toFunction(context); builder.toFunction(context);
assertWarnings("As of version 7.0 Elasticsearch will require that a [field] parameter is provided when a [seed] is set"); assertWarnings(
Level.WARN,
"As of version 7.0 Elasticsearch will require that a [field] parameter is provided when a [seed] is set"
);
} }
public void testRandomScoreFunctionWithSeed() throws Exception { public void testRandomScoreFunctionWithSeed() throws Exception {

View file

@ -8,6 +8,7 @@
package org.elasticsearch.indices.analysis; package org.elasticsearch.indices.analysis;
import org.apache.logging.log4j.Level;
import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.CharFilter; import org.apache.lucene.analysis.CharFilter;
import org.apache.lucene.analysis.MockTokenizer; import org.apache.lucene.analysis.MockTokenizer;
@ -117,7 +118,7 @@ public class AnalysisModuleTests extends ESTestCase {
public void testSimpleConfigurationYaml() throws IOException { public void testSimpleConfigurationYaml() throws IOException {
Settings settings = loadFromClasspath("/org/elasticsearch/index/analysis/test1.yml"); Settings settings = loadFromClasspath("/org/elasticsearch/index/analysis/test1.yml");
testSimpleConfiguration(settings); testSimpleConfiguration(settings);
assertWarnings("Setting [version] on analysis component [custom7] has no effect and is deprecated"); assertWarnings(Level.WARN, "Setting [version] on analysis component [custom7] has no effect and is deprecated");
} }
public void testVersionedAnalyzers() throws Exception { public void testVersionedAnalyzers() throws Exception {
@ -131,7 +132,7 @@ public class AnalysisModuleTests extends ESTestCase {
IndexAnalyzers indexAnalyzers = getIndexAnalyzers(newRegistry, settings2); IndexAnalyzers indexAnalyzers = getIndexAnalyzers(newRegistry, settings2);
assertThat(indexAnalyzers.get("custom7").analyzer(), is(instanceOf(StandardAnalyzer.class))); assertThat(indexAnalyzers.get("custom7").analyzer(), is(instanceOf(StandardAnalyzer.class)));
assertWarnings("Setting [version] on analysis component [custom7] has no effect and is deprecated"); assertWarnings(Level.WARN, "Setting [version] on analysis component [custom7] has no effect and is deprecated");
} }
private void testSimpleConfiguration(Settings settings) throws IOException { private void testSimpleConfiguration(Settings settings) throws IOException {
@ -229,7 +230,7 @@ public class AnalysisModuleTests extends ESTestCase {
.put(IndexMetadata.SETTING_VERSION_CREATED, version) .put(IndexMetadata.SETTING_VERSION_CREATED, version)
.build(); .build();
getIndexAnalyzers(settings); getIndexAnalyzers(settings);
assertWarnings("The [standard] token filter is deprecated and will be removed in a future version."); assertWarnings(Level.WARN, "The [standard] token filter is deprecated and will be removed in a future version.");
} }
} }

View file

@ -9,6 +9,7 @@ package org.elasticsearch.search;
import com.carrotsearch.hppc.IntArrayList; import com.carrotsearch.hppc.IntArrayList;
import org.apache.logging.log4j.Level;
import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.FilterDirectoryReader; import org.apache.lucene.index.FilterDirectoryReader;
import org.apache.lucene.index.LeafReader; import org.apache.lucene.index.LeafReader;
@ -1234,7 +1235,7 @@ public class SearchServiceTests extends ESSingleNodeTestCase {
client().prepareIndex(indexName, "_doc").setId("1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get(); client().prepareIndex(indexName, "_doc").setId("1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();
assertHitCount(client().prepareSearch().get(), 0L); assertHitCount(client().prepareSearch().get(), 0L);
assertHitCount(client().prepareSearch().setIndicesOptions(IndicesOptions.STRICT_EXPAND_OPEN_FORBID_CLOSED).get(), 1L); assertHitCount(client().prepareSearch().setIndicesOptions(IndicesOptions.STRICT_EXPAND_OPEN_FORBID_CLOSED).get(), 1L);
assertWarnings(TransportSearchAction.FROZEN_INDICES_DEPRECATION_MESSAGE.replace("{}", indexName)); assertWarnings(Level.WARN, TransportSearchAction.FROZEN_INDICES_DEPRECATION_MESSAGE.replace("{}", indexName));
} }
public void testCreateReduceContext() { public void testCreateReduceContext() {

View file

@ -8,6 +8,7 @@
package org.elasticsearch.search.aggregations.bucket.histogram; package org.elasticsearch.search.aggregations.bucket.histogram;
import org.apache.logging.log4j.Level;
import org.apache.lucene.document.Document; import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field; import org.apache.lucene.document.Field;
import org.apache.lucene.document.LongPoint; import org.apache.lucene.document.LongPoint;
@ -427,7 +428,7 @@ public class AutoDateHistogramAggregatorTests extends DateHistogramAggregatorTes
d.add(new SortedNumericDocValuesField(fieldName, 0)); d.add(new SortedNumericDocValuesField(fieldName, 0));
iw.addDocument(d); iw.addDocument(d);
}, a -> {}, new BooleanFieldMapper.BooleanFieldType(fieldName)); }, a -> {}, new BooleanFieldMapper.BooleanFieldType(fieldName));
assertWarnings("Running AutoIntervalDateHistogram aggregations on [boolean] fields is deprecated"); assertWarnings(Level.WARN, "Running AutoIntervalDateHistogram aggregations on [boolean] fields is deprecated");
} }
public void testUnmappedMissing() throws IOException { public void testUnmappedMissing() throws IOException {

View file

@ -8,6 +8,7 @@
package org.elasticsearch.search.aggregations.bucket.histogram; package org.elasticsearch.search.aggregations.bucket.histogram;
import org.apache.logging.log4j.Level;
import org.apache.lucene.document.Document; import org.apache.lucene.document.Document;
import org.apache.lucene.document.LongPoint; import org.apache.lucene.document.LongPoint;
import org.apache.lucene.document.NumericDocValuesField; import org.apache.lucene.document.NumericDocValuesField;
@ -103,7 +104,7 @@ public class DateHistogramAggregatorTests extends DateHistogramAggregatorTestCas
a -> {}, a -> {},
new BooleanFieldMapper.BooleanFieldType(fieldName) new BooleanFieldMapper.BooleanFieldType(fieldName)
); );
assertWarnings("Running DateHistogram aggregations on [boolean] fields is deprecated"); assertWarnings(Level.WARN, "Running DateHistogram aggregations on [boolean] fields is deprecated");
} }
public void testMatchNoDocs() throws IOException { public void testMatchNoDocs() throws IOException {

View file

@ -8,6 +8,7 @@
package org.elasticsearch.search.aggregations.bucket.range; package org.elasticsearch.search.aggregations.bucket.range;
import org.apache.logging.log4j.Level;
import org.apache.lucene.document.Document; import org.apache.lucene.document.Document;
import org.apache.lucene.document.IntPoint; import org.apache.lucene.document.IntPoint;
import org.apache.lucene.document.LongPoint; import org.apache.lucene.document.LongPoint;
@ -63,7 +64,7 @@ public class DateRangeAggregatorTests extends AggregatorTestCase {
d.add(new SortedNumericDocValuesField(fieldName, 0)); d.add(new SortedNumericDocValuesField(fieldName, 0));
iw.addDocument(d); iw.addDocument(d);
}, a -> {}, new BooleanFieldMapper.BooleanFieldType(fieldName)); }, a -> {}, new BooleanFieldMapper.BooleanFieldType(fieldName));
assertWarnings("Running Range or DateRange aggregations on [boolean] fields is deprecated"); assertWarnings(Level.WARN, "Running Range or DateRange aggregations on [boolean] fields is deprecated");
} }
public void testNoMatchingField() throws IOException { public void testNoMatchingField() throws IOException {

View file

@ -8,6 +8,7 @@
package org.elasticsearch.index.mapper; package org.elasticsearch.index.mapper;
import org.apache.logging.log4j.Level;
import org.apache.lucene.index.DocValuesType; import org.apache.lucene.index.DocValuesType;
import org.apache.lucene.index.IndexOptions; import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.IndexableField;
@ -21,6 +22,7 @@ import org.apache.lucene.search.TermQuery;
import org.apache.lucene.util.SetOnce; import org.apache.lucene.util.SetOnce;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.core.CheckedConsumer; import org.elasticsearch.core.CheckedConsumer;
import org.elasticsearch.core.Set; import org.elasticsearch.core.Set;
@ -223,17 +225,21 @@ public abstract class MapperTestCase extends MapperServiceTestCase {
assertParseMaximalWarnings(); assertParseMaximalWarnings();
} }
protected Level getWarningLevel() {
return DeprecationLogger.CRITICAL;
}
protected final void assertParseMinimalWarnings() { protected final void assertParseMinimalWarnings() {
String[] warnings = getParseMinimalWarnings(); String[] warnings = getParseMinimalWarnings();
if (warnings.length > 0) { if (warnings.length > 0) {
assertWarnings(warnings); assertWarnings(getWarningLevel(), warnings);
} }
} }
protected final void assertParseMaximalWarnings() { protected final void assertParseMaximalWarnings() {
String[] warnings = getParseMaximalWarnings(); String[] warnings = getParseMaximalWarnings();
if (warnings.length > 0) { if (warnings.length > 0) {
assertWarnings(warnings); assertWarnings(getWarningLevel(), warnings);
} }
} }
@ -728,7 +734,7 @@ public abstract class MapperTestCase extends MapperServiceTestCase {
expectThrows(MapperParsingException.class, () -> mapper.parse(source(b -> b.nullField("field")))); expectThrows(MapperParsingException.class, () -> mapper.parse(source(b -> b.nullField("field"))));
} }
assertWarnings(getParseMinimalWarnings()); assertWarnings(getWarningLevel(), getParseMinimalWarnings());
} }
protected boolean allowsNullValues() { protected boolean allowsNullValues() {

View file

@ -243,7 +243,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.critical(DeprecationCategory.OTHER, "key", "message {}", 123); deprecationLogger.warn(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.critical(DeprecationCategory.OTHER, "to_query", "[deprecated] query"); deprecationLogger.warn(DeprecationCategory.OTHER, "to_query", "[deprecated] query");
return new MatchAllDocsQuery(); return new MatchAllDocsQuery();
} }

View file

@ -424,7 +424,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.critical( deprecationLogger.warn(
DeprecationCategory.OTHER, DeprecationCategory.OTHER,
"config_file_path", "config_file_path",
"Config file [" "Config file ["

View file

@ -375,7 +375,7 @@ public final class IndicesPermission {
for (String privilegeName : group.privilege.name()) { for (String privilegeName : group.privilege.name()) {
if (PRIVILEGE_NAME_SET_BWC_ALLOW_MAPPING_UPDATE.contains(privilegeName)) { if (PRIVILEGE_NAME_SET_BWC_ALLOW_MAPPING_UPDATE.contains(privilegeName)) {
bwcDeprecationLogActions.add(() -> { bwcDeprecationLogActions.add(() -> {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.SECURITY, DeprecationCategory.SECURITY,
"[" + resource.name + "] mapping update for ingest privilege [" + privilegeName + "]", "[" + resource.name + "] mapping update for ingest privilege [" + privilegeName + "]",
"the index privilege [" "the index privilege ["

View file

@ -125,7 +125,7 @@ public class GetTransformAction extends ActionType<GetTransformAction.Response>
builder.field(TransformField.COUNT.getPreferredName(), invalidTransforms.size()); builder.field(TransformField.COUNT.getPreferredName(), invalidTransforms.size());
builder.field(TransformField.TRANSFORMS.getPreferredName(), invalidTransforms); builder.field(TransformField.TRANSFORMS.getPreferredName(), invalidTransforms);
builder.endObject(); builder.endObject();
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.OTHER, DeprecationCategory.OTHER,
"invalid_transforms", "invalid_transforms",
INVALID_TRANSFORMS_DEPRECATION_WARNING, INVALID_TRANSFORMS_DEPRECATION_WARNING,

View file

@ -88,7 +88,7 @@ public class PivotConfig implements Writeable, ToXContentObject {
this.maxPageSearchSize = maxPageSearchSize; this.maxPageSearchSize = maxPageSearchSize;
if (maxPageSearchSize != null) { if (maxPageSearchSize != null) {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.API, DeprecationCategory.API,
TransformField.MAX_PAGE_SEARCH_SIZE.getPreferredName(), TransformField.MAX_PAGE_SEARCH_SIZE.getPreferredName(),
TransformDeprecations.ACTION_MAX_PAGE_SEARCH_SIZE_IS_DEPRECATED TransformDeprecations.ACTION_MAX_PAGE_SEARCH_SIZE_IS_DEPRECATED

View file

@ -97,7 +97,7 @@ public class MockDeprecatedAggregationBuilder extends ValuesSourceAggregationBui
} }
public static MockDeprecatedAggregationBuilder fromXContent(XContentParser p) { public static MockDeprecatedAggregationBuilder fromXContent(XContentParser p) {
deprecationLogger.critical(DeprecationCategory.OTHER, "deprecated_mock", DEPRECATION_MESSAGE); deprecationLogger.warn(DeprecationCategory.OTHER, "deprecated_mock", DEPRECATION_MESSAGE);
return new MockDeprecatedAggregationBuilder(); return new MockDeprecatedAggregationBuilder();
} }
} }

View file

@ -46,7 +46,7 @@ public class MockDeprecatedQueryBuilder extends AbstractQueryBuilder<MockDepreca
public static MockDeprecatedQueryBuilder fromXContent(XContentParser parser) { public static MockDeprecatedQueryBuilder fromXContent(XContentParser parser) {
try { try {
deprecationLogger.critical(DeprecationCategory.OTHER, "deprecated_mock", DEPRECATION_MESSAGE); deprecationLogger.warn(DeprecationCategory.OTHER, "deprecated_mock", DEPRECATION_MESSAGE);
return PARSER.apply(parser, null); return PARSER.apply(parser, null);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {

View file

@ -7,6 +7,7 @@
package org.elasticsearch.xpack.core.transform.action; package org.elasticsearch.xpack.core.transform.action;
import org.apache.logging.log4j.Level;
import org.elasticsearch.common.io.stream.Writeable.Reader; import org.elasticsearch.common.io.stream.Writeable.Reader;
import org.elasticsearch.common.logging.LoggerMessageFormat; import org.elasticsearch.common.logging.LoggerMessageFormat;
import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.common.xcontent.support.XContentMapValues;
@ -52,7 +53,7 @@ public class GetTransformActionResponseTests extends AbstractWireSerializingTran
expectedInvalidTransforms.add(transforms.get(1).getId()); expectedInvalidTransforms.add(transforms.get(1).getId());
expectedInvalidTransforms.add(transforms.get(3).getId()); expectedInvalidTransforms.add(transforms.get(3).getId());
assertEquals(expectedInvalidTransforms, XContentMapValues.extractValue("invalid_transforms.transforms", responseAsMap)); assertEquals(expectedInvalidTransforms, XContentMapValues.extractValue("invalid_transforms.transforms", responseAsMap));
assertWarnings(LoggerMessageFormat.format(Response.INVALID_TRANSFORMS_DEPRECATION_WARNING, 2)); assertWarnings(Level.WARN, LoggerMessageFormat.format(Response.INVALID_TRANSFORMS_DEPRECATION_WARNING, 2));
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

View file

@ -7,6 +7,7 @@
package org.elasticsearch.xpack.core.transform.transforms; package org.elasticsearch.xpack.core.transform.transforms;
import org.apache.logging.log4j.Level;
import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.ValidationException; import org.elasticsearch.common.ValidationException;
import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.bytes.BytesReference;
@ -147,7 +148,7 @@ public class QueryConfigTests extends AbstractSerializingTransformTestCase<Query
try (XContentParser parser = createParser(JsonXContent.jsonXContent, source)) { try (XContentParser parser = createParser(JsonXContent.jsonXContent, source)) {
QueryConfig query = QueryConfig.fromXContent(parser, false); QueryConfig query = QueryConfig.fromXContent(parser, false);
assertNotNull(query.getQuery()); assertNotNull(query.getQuery());
assertWarnings(MockDeprecatedQueryBuilder.DEPRECATION_MESSAGE); assertWarnings(Level.WARN, MockDeprecatedQueryBuilder.DEPRECATION_MESSAGE);
} }
} }
} }

View file

@ -43,6 +43,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static org.apache.logging.log4j.Level.WARN;
import static org.elasticsearch.test.TestMatchers.matchesPattern; import static org.elasticsearch.test.TestMatchers.matchesPattern;
import static org.elasticsearch.xpack.core.transform.transforms.DestConfigTests.randomDestConfig; import static org.elasticsearch.xpack.core.transform.transforms.DestConfigTests.randomDestConfig;
import static org.elasticsearch.xpack.core.transform.transforms.SourceConfigTests.randomInvalidSourceConfig; import static org.elasticsearch.xpack.core.transform.transforms.SourceConfigTests.randomInvalidSourceConfig;
@ -511,7 +512,7 @@ public class TransformConfigTests extends AbstractSerializingTransformTestCase<T
assertTrue(transformConfigRewritten.getSettings().getDatesAsEpochMillis()); assertTrue(transformConfigRewritten.getSettings().getDatesAsEpochMillis());
assertFalse(transformConfigRewritten.getSettings().getAlignCheckpoints()); assertFalse(transformConfigRewritten.getSettings().getAlignCheckpoints());
assertWarnings(TransformDeprecations.ACTION_MAX_PAGE_SEARCH_SIZE_IS_DEPRECATED); assertWarnings(WARN, TransformDeprecations.ACTION_MAX_PAGE_SEARCH_SIZE_IS_DEPRECATED);
assertEquals(Version.CURRENT, transformConfigRewritten.getVersion()); assertEquals(Version.CURRENT, transformConfigRewritten.getVersion());
} }
@ -584,7 +585,7 @@ public class TransformConfigTests extends AbstractSerializingTransformTestCase<T
assertNotNull(transformConfigRewritten.getSettings().getMaxPageSearchSize()); assertNotNull(transformConfigRewritten.getSettings().getMaxPageSearchSize());
assertEquals(555L, transformConfigRewritten.getSettings().getMaxPageSearchSize().longValue()); assertEquals(555L, transformConfigRewritten.getSettings().getMaxPageSearchSize().longValue());
assertEquals(Version.CURRENT, transformConfigRewritten.getVersion()); assertEquals(Version.CURRENT, transformConfigRewritten.getVersion());
assertWarnings(TransformDeprecations.ACTION_MAX_PAGE_SEARCH_SIZE_IS_DEPRECATED); assertWarnings(WARN, TransformDeprecations.ACTION_MAX_PAGE_SEARCH_SIZE_IS_DEPRECATED);
} }
public void testRewriteForBWCOfDateNormalization() throws IOException { public void testRewriteForBWCOfDateNormalization() throws IOException {
@ -740,7 +741,7 @@ public class TransformConfigTests extends AbstractSerializingTransformTestCase<T
TransformConfig deprecatedConfig = randomTransformConfigWithDeprecatedFields(id, Version.CURRENT); TransformConfig deprecatedConfig = randomTransformConfigWithDeprecatedFields(id, Version.CURRENT);
// check _and_ clear warnings // check _and_ clear warnings
assertWarnings(TransformDeprecations.ACTION_MAX_PAGE_SEARCH_SIZE_IS_DEPRECATED); assertWarnings(WARN, TransformDeprecations.ACTION_MAX_PAGE_SEARCH_SIZE_IS_DEPRECATED);
// important: checkForDeprecations does _not_ create new deprecation warnings // important: checkForDeprecations does _not_ create new deprecation warnings
assertThat( assertThat(
@ -765,7 +766,7 @@ public class TransformConfigTests extends AbstractSerializingTransformTestCase<T
deprecatedConfig = randomTransformConfigWithDeprecatedFields(id, Version.V_7_10_0); deprecatedConfig = randomTransformConfigWithDeprecatedFields(id, Version.V_7_10_0);
// check _and_ clear warnings // check _and_ clear warnings
assertWarnings(TransformDeprecations.ACTION_MAX_PAGE_SEARCH_SIZE_IS_DEPRECATED); assertWarnings(WARN, TransformDeprecations.ACTION_MAX_PAGE_SEARCH_SIZE_IS_DEPRECATED);
// important: checkForDeprecations does _not_ create new deprecation warnings // important: checkForDeprecations does _not_ create new deprecation warnings
assertThat( assertThat(
@ -790,7 +791,7 @@ public class TransformConfigTests extends AbstractSerializingTransformTestCase<T
deprecatedConfig = randomTransformConfigWithDeprecatedFields(id, Version.V_7_4_0); deprecatedConfig = randomTransformConfigWithDeprecatedFields(id, Version.V_7_4_0);
// check _and_ clear warnings // check _and_ clear warnings
assertWarnings(TransformDeprecations.ACTION_MAX_PAGE_SEARCH_SIZE_IS_DEPRECATED); assertWarnings(WARN, TransformDeprecations.ACTION_MAX_PAGE_SEARCH_SIZE_IS_DEPRECATED);
// important: checkForDeprecations does _not_ create new deprecation warnings // important: checkForDeprecations does _not_ create new deprecation warnings
assertThat( assertThat(

View file

@ -7,6 +7,7 @@
package org.elasticsearch.xpack.core.transform.transforms.pivot; package org.elasticsearch.xpack.core.transform.transforms.pivot;
import org.apache.logging.log4j.Level;
import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.ValidationException; import org.elasticsearch.common.ValidationException;
import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.bytes.BytesReference;
@ -137,7 +138,7 @@ public class AggregationConfigTests extends AbstractSerializingTransformTestCase
try (XContentParser parser = createParser(JsonXContent.jsonXContent, source)) { try (XContentParser parser = createParser(JsonXContent.jsonXContent, source)) {
AggregationConfig agg = AggregationConfig.fromXContent(parser, false); AggregationConfig agg = AggregationConfig.fromXContent(parser, false);
assertNull(agg.validate(null)); assertNull(agg.validate(null));
assertWarnings(MockDeprecatedAggregationBuilder.DEPRECATION_MESSAGE); assertWarnings(Level.WARN, MockDeprecatedAggregationBuilder.DEPRECATION_MESSAGE);
} }
} }

View file

@ -7,6 +7,7 @@
package org.elasticsearch.xpack.core.transform.transforms.pivot; package org.elasticsearch.xpack.core.transform.transforms.pivot;
import org.apache.logging.log4j.Level;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
import org.elasticsearch.common.ValidationException; import org.elasticsearch.common.ValidationException;
@ -438,7 +439,7 @@ public class PivotConfigTests extends AbstractSerializingTransformTestCase<Pivot
public void testDeprecation() { public void testDeprecation() {
PivotConfig pivotConfig = randomPivotConfigWithDeprecatedFields(); PivotConfig pivotConfig = randomPivotConfigWithDeprecatedFields();
assertWarnings(TransformDeprecations.ACTION_MAX_PAGE_SEARCH_SIZE_IS_DEPRECATED); assertWarnings(Level.WARN, TransformDeprecations.ACTION_MAX_PAGE_SEARCH_SIZE_IS_DEPRECATED);
} }
private static String dotJoin(String... fields) { private static String dotJoin(String... fields) {

View file

@ -67,7 +67,7 @@ public class TestDeprecatedQueryBuilder extends AbstractQueryBuilder<TestDepreca
@Override @Override
protected Query doToQuery(SearchExecutionContext context) throws IOException { protected Query doToQuery(SearchExecutionContext context) throws IOException {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.OTHER, DeprecationCategory.OTHER,
NAME, NAME,
"[{}] query is deprecated, but used on [{}] index", "[{}] query is deprecated, but used on [{}] index",

View file

@ -1069,6 +1069,7 @@ public class NodeDeprecationChecksTests extends ESTestCase {
equalTo(expectedIssue) equalTo(expectedIssue)
); );
assertWarnings( assertWarnings(
Level.WARN,
String.format( String.format(
Locale.ROOT, Locale.ROOT,
"Fractional bytes values are deprecated. Use non-fractional bytes values instead: [%s] " + "found for setting [%s]", "Fractional bytes values are deprecated. Use non-fractional bytes values instead: [%s] " + "found for setting [%s]",

View file

@ -6,6 +6,7 @@
*/ */
package org.elasticsearch.index.engine.frozen; package org.elasticsearch.index.engine.frozen;
import org.apache.logging.log4j.Level;
import org.elasticsearch.action.OriginalIndices; import org.elasticsearch.action.OriginalIndices;
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse; import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
@ -162,7 +163,7 @@ public class FrozenIndexTests extends ESSingleNodeTestCase {
assertFalse(((FrozenEngine) engine).isReaderOpen()); assertFalse(((FrozenEngine) engine).isReaderOpen());
} }
} }
assertWarnings(TransportSearchAction.FROZEN_INDICES_DEPRECATION_MESSAGE.replace("{}", indexName)); assertWarnings(Level.WARN, TransportSearchAction.FROZEN_INDICES_DEPRECATION_MESSAGE.replace("{}", indexName));
} finally { } finally {
client().execute(ClosePointInTimeAction.INSTANCE, new ClosePointInTimeRequest(pitId)).get(); client().execute(ClosePointInTimeAction.INSTANCE, new ClosePointInTimeRequest(pitId)).get();
} }
@ -218,7 +219,7 @@ public class FrozenIndexTests extends ESSingleNodeTestCase {
} }
IndicesStatsResponse index = client().admin().indices().prepareStats(indexName).clear().setRefresh(true).get(); IndicesStatsResponse index = client().admin().indices().prepareStats(indexName).clear().setRefresh(true).get();
assertEquals(numRefreshes, index.getTotal().refresh.getTotal()); assertEquals(numRefreshes, index.getTotal().refresh.getTotal());
assertWarnings(TransportSearchAction.FROZEN_INDICES_DEPRECATION_MESSAGE.replace("{}", indexName)); assertWarnings(Level.WARN, TransportSearchAction.FROZEN_INDICES_DEPRECATION_MESSAGE.replace("{}", indexName));
} }
public void testFreezeAndUnfreeze() throws ExecutionException, InterruptedException { public void testFreezeAndUnfreeze() throws ExecutionException, InterruptedException {
@ -323,7 +324,7 @@ public class FrozenIndexTests extends ESSingleNodeTestCase {
assertEquals(1, index.getTotal().refresh.getTotal()); assertEquals(1, index.getTotal().refresh.getTotal());
index = client().admin().indices().prepareStats("test-idx-1").clear().setRefresh(true).get(); index = client().admin().indices().prepareStats("test-idx-1").clear().setRefresh(true).get();
assertEquals(0, index.getTotal().refresh.getTotal()); assertEquals(0, index.getTotal().refresh.getTotal());
assertWarnings(TransportSearchAction.FROZEN_INDICES_DEPRECATION_MESSAGE.replace("{}", indexName)); assertWarnings(Level.WARN, TransportSearchAction.FROZEN_INDICES_DEPRECATION_MESSAGE.replace("{}", indexName));
} }
public void testCanMatch() throws IOException, ExecutionException, InterruptedException { public void testCanMatch() throws IOException, ExecutionException, InterruptedException {

View file

@ -75,7 +75,7 @@ public class RestGetTrainedModelsAction extends BaseRestHandler {
); );
final GetTrainedModelsAction.Request request; final GetTrainedModelsAction.Request request;
if (restRequest.hasParam(GetTrainedModelsAction.Request.INCLUDE_MODEL_DEFINITION)) { if (restRequest.hasParam(GetTrainedModelsAction.Request.INCLUDE_MODEL_DEFINITION)) {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.API, DeprecationCategory.API,
GetTrainedModelsAction.Request.INCLUDE_MODEL_DEFINITION, GetTrainedModelsAction.Request.INCLUDE_MODEL_DEFINITION,
"[{}] parameter is deprecated! Use [include=definition] instead.", "[{}] parameter is deprecated! Use [include=definition] instead.",

View file

@ -163,7 +163,7 @@ public final class DomainSplitFunction {
public static List<String> domainSplit(String host, Map<String, Object> params) { public static List<String> domainSplit(String host, Map<String, Object> params) {
// NOTE: we don't check SpecialPermission because this will be called (indirectly) from scripts // NOTE: we don't check SpecialPermission because this will be called (indirectly) from scripts
AccessController.doPrivileged((PrivilegedAction<Void>) () -> { AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.API, DeprecationCategory.API,
"domainSplit", "domainSplit",
"Method [domainSplit] taking params is deprecated. Remove the params argument." "Method [domainSplit] taking params is deprecated. Remove the params argument."

View file

@ -119,7 +119,7 @@ public class TransportPutRollupJobAction extends AcknowledgedTransportMasterNode
String timeZone = request.getConfig().getGroupConfig().getDateHistogram().getTimeZone(); String timeZone = request.getConfig().getGroupConfig().getDateHistogram().getTimeZone();
String modernTZ = DateUtils.DEPRECATED_LONG_TIMEZONES.get(timeZone); String modernTZ = DateUtils.DEPRECATED_LONG_TIMEZONES.get(timeZone);
if (modernTZ != null) { if (modernTZ != null) {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.API, DeprecationCategory.API,
"deprecated_timezone", "deprecated_timezone",
"Creating Rollup job [" "Creating Rollup job ["

View file

@ -6,6 +6,7 @@
*/ */
package org.elasticsearch.xpack.rollup.action; package org.elasticsearch.xpack.rollup.action;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.elasticsearch.ResourceAlreadyExistsException; import org.elasticsearch.ResourceAlreadyExistsException;
import org.elasticsearch.Version; import org.elasticsearch.Version;
@ -466,6 +467,7 @@ public class PutJobStateMachineTests extends ESTestCase {
PutRollupJobAction.Request request = new PutRollupJobAction.Request(config); PutRollupJobAction.Request request = new PutRollupJobAction.Request(config);
TransportPutRollupJobAction.checkForDeprecatedTZ(request); TransportPutRollupJobAction.checkForDeprecatedTZ(request);
assertWarnings( assertWarnings(
Level.WARN,
"Creating Rollup job [foo] with timezone [Japan], but [Japan] has been deprecated by the IANA. " + "Use [Asia/Tokyo] instead." "Creating Rollup job [foo] with timezone [Japan], but [Japan] has been deprecated by the IANA. " + "Use [Asia/Tokyo] instead."
); );
} }

View file

@ -972,7 +972,7 @@ public class ApiKeyService {
@Override @Override
public void usedDeprecatedName(String parserName, Supplier<XContentLocation> location, String usedName, String modernName) { public void usedDeprecatedName(String parserName, Supplier<XContentLocation> location, String usedName, String modernName) {
String prefix = parserName == null ? "" : "[" + parserName + "][" + location.get() + "] "; String prefix = parserName == null ? "" : "[" + parserName + "][" + location.get() + "] ";
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.SECURITY, DeprecationCategory.SECURITY,
"api_key_field", "api_key_field",
"{}Deprecated field [{}] used in api key [{}], expected [{}] instead", "{}Deprecated field [{}] used in api key [{}], expected [{}] instead",
@ -986,7 +986,7 @@ public class ApiKeyService {
@Override @Override
public void usedDeprecatedField(String parserName, Supplier<XContentLocation> location, String usedName, String replacedWith) { public void usedDeprecatedField(String parserName, Supplier<XContentLocation> location, String usedName, String replacedWith) {
String prefix = parserName == null ? "" : "[" + parserName + "][" + location.get() + "] "; String prefix = parserName == null ? "" : "[" + parserName + "][" + location.get() + "] ";
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.SECURITY, DeprecationCategory.SECURITY,
"api_key_field", "api_key_field",
"{}Deprecated field [{}] used in api key [{}], replaced by [{}]", "{}Deprecated field [{}] used in api key [{}], replaced by [{}]",
@ -1000,7 +1000,7 @@ public class ApiKeyService {
@Override @Override
public void usedDeprecatedField(String parserName, Supplier<XContentLocation> location, String usedName) { public void usedDeprecatedField(String parserName, Supplier<XContentLocation> location, String usedName) {
String prefix = parserName == null ? "" : "[" + parserName + "][" + location.get() + "] "; String prefix = parserName == null ? "" : "[" + parserName + "][" + location.get() + "] ";
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.SECURITY, DeprecationCategory.SECURITY,
"api_key_field", "api_key_field",
"{}Deprecated field [{}] used in api key [{}], which is unused and will be removed entirely", "{}Deprecated field [{}] used in api key [{}], which is unused and will be removed entirely",

View file

@ -513,7 +513,7 @@ public class Realms implements Iterable<Realm> {
private void logDeprecationForReservedPrefixedRealmNames(List<RealmConfig.RealmIdentifier> realmIdentifiers) { private void logDeprecationForReservedPrefixedRealmNames(List<RealmConfig.RealmIdentifier> realmIdentifiers) {
if (false == realmIdentifiers.isEmpty()) { if (false == realmIdentifiers.isEmpty()) {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.SECURITY, DeprecationCategory.SECURITY,
"realm_name_with_reserved_prefix", "realm_name_with_reserved_prefix",
"Found realm " "Found realm "

View file

@ -247,7 +247,7 @@ public class ReservedRealm extends CachingUsernamePasswordRealm {
private void logDeprecatedUser(final User user) { private void logDeprecatedUser(final User user) {
Map<String, Object> metadata = user.metadata(); Map<String, Object> metadata = user.metadata();
if (Boolean.TRUE.equals(metadata.get(MetadataUtils.DEPRECATED_METADATA_KEY))) { if (Boolean.TRUE.equals(metadata.get(MetadataUtils.DEPRECATED_METADATA_KEY))) {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.SECURITY, DeprecationCategory.SECURITY,
"deprecated_user-" + user.principal(), "deprecated_user-" + user.principal(),
"The user [" "The user ["

View file

@ -720,7 +720,7 @@ class ActiveDirectorySessionFactory extends PoolingSessionFactory {
threadPool threadPool
); );
if (userSearchFilter.contains("{0}")) { if (userSearchFilter.contains("{0}")) {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.SECURITY, DeprecationCategory.SECURITY,
"ldap_settings", "ldap_settings",
"The use of the account name variable {0} in the setting [" "The use of the account name variable {0} in the setting ["

View file

@ -170,7 +170,7 @@ public abstract class SessionFactory {
final String fullSettingKey = RealmSettings.getFullSettingKey(config, SessionFactorySettings.HOSTNAME_VERIFICATION_SETTING); final String fullSettingKey = RealmSettings.getFullSettingKey(config, SessionFactorySettings.HOSTNAME_VERIFICATION_SETTING);
final String deprecationKey = "deprecated_setting_" + fullSettingKey.replace('.', '_'); final String deprecationKey = "deprecated_setting_" + fullSettingKey.replace('.', '_');
DeprecationLogger.getLogger(logger.getName()) DeprecationLogger.getLogger(logger.getName())
.critical( .warn(
DeprecationCategory.SECURITY, DeprecationCategory.SECURITY,
deprecationKey, deprecationKey,
"the setting [{}] has been deprecated and will be removed in a future version. use [{}] instead", "the setting [{}] has been deprecated and will be removed in a future version. use [{}] instead",

View file

@ -226,7 +226,7 @@ public class CompositeRolesStore {
rd.getMetadata().get(MetadataUtils.DEPRECATED_REASON_METADATA_KEY), rd.getMetadata().get(MetadataUtils.DEPRECATED_REASON_METADATA_KEY),
"Please check the documentation" "Please check the documentation"
); );
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.SECURITY, DeprecationCategory.SECURITY,
"deprecated_role-" + rd.getName(), "deprecated_role-" + rd.getName(),
"The role [" + rd.getName() + "] is deprecated and will be removed in a future version of Elasticsearch. " + reason "The role [" + rd.getName() + "] is deprecated and will be removed in a future version of Elasticsearch. " + reason

View file

@ -211,7 +211,7 @@ public final class DeprecationRoleDescriptorConsumer implements Consumer<Collect
aliasName, aliasName,
String.join(", ", inferiorIndexNames) String.join(", ", inferiorIndexNames)
); );
deprecationLogger.critical(DeprecationCategory.SECURITY, "index_permissions_on_alias", logMessage); deprecationLogger.warn(DeprecationCategory.SECURITY, "index_permissions_on_alias", logMessage);
} }
} }
} }

View file

@ -1054,6 +1054,7 @@ public class RealmsTests extends ESTestCase {
new Realms(settings, env, factories, licenseState, threadContext, reservedRealm); new Realms(settings, env, factories, licenseState, threadContext, reservedRealm);
assertWarnings( assertWarnings(
Level.WARN,
"Found realm " "Found realm "
+ (invalidRealmNames.size() == 1 ? "name" : "names") + (invalidRealmNames.size() == 1 ? "name" : "names")
+ " with reserved prefix [_]: [" + " with reserved prefix [_]: ["

View file

@ -10,6 +10,7 @@ import com.unboundid.ldap.sdk.LDAPConnectionOptions;
import com.unboundid.util.ssl.HostNameSSLSocketVerifier; import com.unboundid.util.ssl.HostNameSSLSocketVerifier;
import com.unboundid.util.ssl.TrustAllSSLSocketVerifier; import com.unboundid.util.ssl.TrustAllSSLSocketVerifier;
import org.apache.logging.log4j.Level;
import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.action.support.PlainActionFuture;
import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.SecureString;
@ -157,6 +158,7 @@ public class SessionFactoryTests extends ESTestCase {
assertThat(options.getResponseTimeoutMillis(), is(equalTo(20L))); assertThat(options.getResponseTimeoutMillis(), is(equalTo(20L)));
assertThat(options.getSSLSocketVerifier(), is(instanceOf(TrustAllSSLSocketVerifier.class))); assertThat(options.getSSLSocketVerifier(), is(instanceOf(TrustAllSSLSocketVerifier.class)));
assertWarnings( assertWarnings(
Level.WARN,
"the setting [xpack.security.authc.realms.ldap.conn_settings.hostname_verification] has been deprecated and will be " "the setting [xpack.security.authc.realms.ldap.conn_settings.hostname_verification] has been deprecated and will be "
+ "removed in a future version. use [xpack.security.authc.realms.ldap.conn_settings.ssl.verification_mode] instead" + "removed in a future version. use [xpack.security.authc.realms.ldap.conn_settings.ssl.verification_mode] instead"
); );

View file

@ -6,6 +6,7 @@
*/ */
package org.elasticsearch.xpack.security.authz.accesscontrol; package org.elasticsearch.xpack.security.authz.accesscontrol;
import org.apache.logging.log4j.Level;
import org.elasticsearch.ElasticsearchSecurityException; import org.elasticsearch.ElasticsearchSecurityException;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.action.admin.indices.mapping.put.AutoPutMappingAction; import org.elasticsearch.action.admin.indices.mapping.put.AutoPutMappingAction;
@ -503,6 +504,7 @@ public class IndicesPermissionTests extends ESTestCase {
assertThat(iac.getIndexPermissions("test1").isGranted(), is(true)); assertThat(iac.getIndexPermissions("test1").isGranted(), is(true));
assertThat(iac.getIndexPermissions("test_write1").isGranted(), is(true)); assertThat(iac.getIndexPermissions("test_write1").isGranted(), is(true));
assertWarnings( assertWarnings(
Level.WARN,
"the index privilege [index] allowed the update mapping action [" "the index privilege [index] allowed the update mapping action ["
+ PutMappingAction.NAME + PutMappingAction.NAME
+ "] on " + "] on "
@ -523,6 +525,7 @@ public class IndicesPermissionTests extends ESTestCase {
assertThat(iac.getIndexPermissions("test1").isGranted(), is(true)); assertThat(iac.getIndexPermissions("test1").isGranted(), is(true));
assertThat(iac.getIndexPermissions("test_write1").isGranted(), is(true)); assertThat(iac.getIndexPermissions("test_write1").isGranted(), is(true));
assertWarnings( assertWarnings(
Level.WARN,
"the index privilege [index] allowed the update mapping action [" "the index privilege [index] allowed the update mapping action ["
+ AutoPutMappingAction.NAME + AutoPutMappingAction.NAME
+ "] on " + "] on "

View file

@ -6,6 +6,7 @@
*/ */
package org.elasticsearch.xpack.security.authz.store; package org.elasticsearch.xpack.security.authz.store;
import org.apache.logging.log4j.Level;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsAction; import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsAction;
@ -1456,6 +1457,7 @@ public class CompositeRolesStoreTests extends ESTestCase {
compositeRolesStore.logDeprecatedRoles(new LinkedHashSet<>(descriptors)); compositeRolesStore.logDeprecatedRoles(new LinkedHashSet<>(descriptors));
assertWarnings( assertWarnings(
Level.WARN,
"The role [" "The role ["
+ deprecated1.getName() + deprecated1.getName()
+ "] is deprecated and will be removed in a future version of Elasticsearch." + "] is deprecated and will be removed in a future version of Elasticsearch."

View file

@ -368,7 +368,7 @@ public final class DeprecationRoleDescriptorConsumerTests extends ESTestCase {
} }
private void verifyLogger(DeprecationLogger deprecationLogger, String roleName, String aliasName, String indexNames) { private void verifyLogger(DeprecationLogger deprecationLogger, String roleName, String aliasName, String indexNames) {
verify(deprecationLogger).critical( verify(deprecationLogger).warn(
DeprecationCategory.SECURITY, DeprecationCategory.SECURITY,
"index_permissions_on_alias", "index_permissions_on_alias",
"Role [" "Role ["

View file

@ -119,7 +119,7 @@ public class GeoShapeWithDocValuesFieldMapper extends AbstractShapeGeometryField
@Override @Override
public GeoShapeWithDocValuesFieldMapper build(MapperBuilderContext context) { public GeoShapeWithDocValuesFieldMapper build(MapperBuilderContext context) {
if (multiFieldsBuilder.hasMultiFields()) { if (multiFieldsBuilder.hasMultiFields()) {
DEPRECATION_LOGGER.critical( DEPRECATION_LOGGER.warn(
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

@ -93,7 +93,7 @@ public class PointFieldMapper extends AbstractPointGeometryFieldMapper<Cartesian
@Override @Override
public FieldMapper build(MapperBuilderContext context) { public FieldMapper build(MapperBuilderContext context) {
if (multiFieldsBuilder.hasMultiFields()) { if (multiFieldsBuilder.hasMultiFields()) {
DEPRECATION_LOGGER.critical( DEPRECATION_LOGGER.warn(
DeprecationCategory.MAPPINGS, DeprecationCategory.MAPPINGS,
"point_multifields", "point_multifields",
"Adding multifields to [point] mappers has no effect and will be forbidden in future" "Adding multifields to [point] mappers has no effect and will be forbidden in future"

View file

@ -82,7 +82,7 @@ public class ShapeFieldMapper extends AbstractShapeGeometryFieldMapper<Geometry>
@Override @Override
public ShapeFieldMapper build(MapperBuilderContext context) { public ShapeFieldMapper build(MapperBuilderContext context) {
if (multiFieldsBuilder.hasMultiFields()) { if (multiFieldsBuilder.hasMultiFields()) {
DEPRECATION_LOGGER.critical( DEPRECATION_LOGGER.warn(
DeprecationCategory.MAPPINGS, DeprecationCategory.MAPPINGS,
"shape_multifields", "shape_multifields",
"Adding multifields to [shape] mappers has no effect and will be forbidden in future" "Adding multifields to [shape] mappers has no effect and will be forbidden in future"

View file

@ -6,6 +6,7 @@
*/ */
package org.elasticsearch.xpack.spatial.index.mapper; package org.elasticsearch.xpack.spatial.index.mapper;
import org.apache.logging.log4j.Level;
import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.IndexableField;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
@ -386,7 +387,7 @@ public class GeoShapeWithDocValuesFieldMapperTests extends MapperTestCase {
b.startObject("keyword").field("type", "keyword").endObject(); b.startObject("keyword").field("type", "keyword").endObject();
b.endObject(); b.endObject();
})); }));
assertWarnings("Adding multifields to [geo_shape] mappers has no effect and will be forbidden in future"); assertWarnings(Level.WARN, "Adding multifields to [geo_shape] mappers has no effect and will be forbidden in future");
} }
public void testRandomVersionMapping() throws Exception { public void testRandomVersionMapping() throws Exception {

View file

@ -6,6 +6,7 @@
*/ */
package org.elasticsearch.xpack.spatial.index.mapper; package org.elasticsearch.xpack.spatial.index.mapper;
import org.apache.logging.log4j.Level;
import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRef;
import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.MappedFieldType;
@ -232,7 +233,7 @@ public class PointFieldMapperTests extends CartesianFieldMapperTests {
b.startObject("keyword").field("type", "keyword").endObject(); b.startObject("keyword").field("type", "keyword").endObject();
b.endObject(); b.endObject();
})); }));
assertWarnings("Adding multifields to [point] mappers has no effect and will be forbidden in future"); assertWarnings(Level.WARN, "Adding multifields to [point] mappers has no effect and will be forbidden in future");
} }
@Override @Override

View file

@ -6,6 +6,7 @@
*/ */
package org.elasticsearch.xpack.spatial.index.mapper; package org.elasticsearch.xpack.spatial.index.mapper;
import org.apache.logging.log4j.Level;
import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.IndexableField;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
import org.elasticsearch.common.geo.Orientation; import org.elasticsearch.common.geo.Orientation;
@ -247,7 +248,7 @@ public class ShapeFieldMapperTests extends CartesianFieldMapperTests {
b.startObject("keyword").field("type", "keyword").endObject(); b.startObject("keyword").field("type", "keyword").endObject();
b.endObject(); b.endObject();
})); }));
assertWarnings("Adding multifields to [shape] mappers has no effect and will be forbidden in future"); assertWarnings(Level.WARN, "Adding multifields to [shape] mappers has no effect and will be forbidden in future");
} }
public String toXContentString(ShapeFieldMapper mapper) { public String toXContentString(ShapeFieldMapper mapper) {

View file

@ -7,6 +7,7 @@
package org.elasticsearch.xpack.transform.transforms.pivot; package org.elasticsearch.xpack.transform.transforms.pivot;
import org.apache.logging.log4j.Level;
import org.apache.lucene.search.TotalHits; import org.apache.lucene.search.TotalHits;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionListener;
@ -137,7 +138,7 @@ public class PivotTests extends ESTestCase {
); );
assertThat(pivot.getInitialPageSize(), equalTo(Transform.DEFAULT_INITIAL_MAX_PAGE_SEARCH_SIZE)); assertThat(pivot.getInitialPageSize(), equalTo(Transform.DEFAULT_INITIAL_MAX_PAGE_SEARCH_SIZE));
assertWarnings(TransformDeprecations.ACTION_MAX_PAGE_SEARCH_SIZE_IS_DEPRECATED); assertWarnings(Level.WARN, TransformDeprecations.ACTION_MAX_PAGE_SEARCH_SIZE_IS_DEPRECATED);
} }
public void testSearchFailure() throws Exception { public void testSearchFailure() throws Exception {

View file

@ -80,7 +80,7 @@ public class SparseVectorFieldMapper extends FieldMapper {
} }
public static final TypeParser PARSER = new TypeParser((n, c) -> { public static final TypeParser PARSER = new TypeParser((n, c) -> {
deprecationLogger.critical(DeprecationCategory.API, "sparse_vector", DEPRECATION_MESSAGE); deprecationLogger.warn(DeprecationCategory.API, "sparse_vector", DEPRECATION_MESSAGE);
return new Builder(n, c.indexVersionCreated()); return new Builder(n, c.indexVersionCreated());
}, notInMultiFields(CONTENT_TYPE)); }, notInMultiFields(CONTENT_TYPE));

View file

@ -7,6 +7,7 @@
package org.elasticsearch.xpack.vectors.mapper; package org.elasticsearch.xpack.vectors.mapper;
import org.apache.logging.log4j.Level;
import org.apache.lucene.document.BinaryDocValuesField; import org.apache.lucene.document.BinaryDocValuesField;
import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.IndexableField;
import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRef;
@ -104,7 +105,7 @@ public class SparseVectorFieldMapperTests extends MapperTestCase {
float decodedMagnitude = VectorEncoderDecoder.decodeMagnitude(indexVersion, vectorBR); float decodedMagnitude = VectorEncoderDecoder.decodeMagnitude(indexVersion, vectorBR);
assertEquals(expectedMagnitude, decodedMagnitude, 0.001f); assertEquals(expectedMagnitude, decodedMagnitude, 0.001f);
assertWarnings(SparseVectorFieldMapper.DEPRECATION_MESSAGE); assertWarnings(Level.WARN, SparseVectorFieldMapper.DEPRECATION_MESSAGE);
} }
public void testAddDocumentsToIndexBefore_V_7_5_0() throws Exception { public void testAddDocumentsToIndexBefore_V_7_5_0() throws Exception {
@ -135,7 +136,7 @@ public class SparseVectorFieldMapperTests extends MapperTestCase {
float[] decodedValues = VectorEncoderDecoder.decodeSparseVector(indexVersion, vectorBR); float[] decodedValues = VectorEncoderDecoder.decodeSparseVector(indexVersion, vectorBR);
assertArrayEquals("Decoded sparse vector values are not equal to the indexed ones.", expectedValues, decodedValues, 0.001f); assertArrayEquals("Decoded sparse vector values are not equal to the indexed ones.", expectedValues, decodedValues, 0.001f);
assertWarnings(SparseVectorFieldMapper.DEPRECATION_MESSAGE); assertWarnings(Level.WARN, SparseVectorFieldMapper.DEPRECATION_MESSAGE);
} }
public void testDimensionNumberValidation() throws IOException { public void testDimensionNumberValidation() throws IOException {
@ -196,7 +197,7 @@ public class SparseVectorFieldMapperTests extends MapperTestCase {
containsString("takes an object that maps a dimension number to a float, but got unexpected token [START_ARRAY]") containsString("takes an object that maps a dimension number to a float, but got unexpected token [START_ARRAY]")
); );
assertWarnings(SparseVectorFieldMapper.DEPRECATION_MESSAGE); assertWarnings(Level.WARN, SparseVectorFieldMapper.DEPRECATION_MESSAGE);
} }
public void testDimensionLimit() throws IOException { public void testDimensionLimit() throws IOException {
@ -218,7 +219,7 @@ public class SparseVectorFieldMapperTests extends MapperTestCase {
); );
assertThat(e.getDetailedMessage(), containsString("has exceeded the maximum allowed number of dimensions")); assertThat(e.getDetailedMessage(), containsString("has exceeded the maximum allowed number of dimensions"));
assertWarnings(SparseVectorFieldMapper.DEPRECATION_MESSAGE); assertWarnings(Level.WARN, SparseVectorFieldMapper.DEPRECATION_MESSAGE);
} }
@Override @Override
@ -254,4 +255,8 @@ public class SparseVectorFieldMapperTests extends MapperTestCase {
}))); })));
assertThat(e.getMessage(), containsString("Field [vectors] of type [sparse_vector] can't be used in multifields")); assertThat(e.getMessage(), containsString("Field [vectors] of type [sparse_vector] can't be used in multifields"));
} }
protected Level getWarningLevel() {
return Level.WARN;
}
} }

View file

@ -62,7 +62,7 @@ public class RestWatcherStatsAction extends WatcherRestHandler {
} }
if (metrics.contains("pending_watches")) { if (metrics.contains("pending_watches")) {
deprecationLogger.critical( deprecationLogger.warn(
DeprecationCategory.API, DeprecationCategory.API,
"pending_watches", "pending_watches",
"The pending_watches parameter is deprecated, use queued_watches instead" "The pending_watches parameter is deprecated, use queued_watches instead"