From 10d72b05c12d2c63f4c0187172e36e3afaedcf9f Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Thu, 19 Mar 2020 12:28:47 +0000 Subject: [PATCH] Revert "Report parser name and location in XContent deprecation warnings (#53752)" This reverts commit 7636930ceb0c20ea34f2b9db42094a0a2af75f03. --- .../org/elasticsearch/common/ParseField.java | 24 ++-------- .../common/xcontent/DeprecationHandler.java | 48 ++++++------------- .../common/xcontent/ObjectParser.java | 2 +- .../common/xcontent/XContentLocation.java | 5 +- .../elasticsearch/common/ParseFieldTests.java | 6 +-- .../common/xcontent/ObjectParserTests.java | 2 +- .../common/ScriptProcessorFactoryTests.java | 2 +- .../xcontent/LoggingDeprecationHandler.java | 20 +++----- .../index/query/BoolQueryBuilderTests.java | 2 +- .../script/StoredScriptTests.java | 2 +- ...LoggingDeprecationAccumulationHandler.java | 29 +++++------ .../utils/XContentObjectTransformerTests.java | 4 +- .../inference/ingest/InferenceProcessor.java | 2 +- .../xpack/security/authc/ApiKeyService.java | 23 ++++----- .../test/ml/data_frame_analytics_crud.yml | 2 +- 15 files changed, 58 insertions(+), 115 deletions(-) diff --git a/libs/x-content/src/main/java/org/elasticsearch/common/ParseField.java b/libs/x-content/src/main/java/org/elasticsearch/common/ParseField.java index 3872ef4852274..f4f12ed4f4c81 100644 --- a/libs/x-content/src/main/java/org/elasticsearch/common/ParseField.java +++ b/libs/x-content/src/main/java/org/elasticsearch/common/ParseField.java @@ -19,13 +19,11 @@ package org.elasticsearch.common; import org.elasticsearch.common.xcontent.DeprecationHandler; -import org.elasticsearch.common.xcontent.XContentLocation; import java.util.Collections; import java.util.HashSet; import java.util.Objects; import java.util.Set; -import java.util.function.Supplier; /** * Holds a field that can be found in a request while parsing and its different @@ -117,22 +115,6 @@ public ParseField withAllDeprecated() { * names for this {@link ParseField}. */ public boolean match(String fieldName, DeprecationHandler deprecationHandler) { - return match(null, () -> XContentLocation.UNKNOWN, fieldName, deprecationHandler); - } - - /** - * Does {@code fieldName} match this field? - * @param parserName - * the name of the parent object holding this field - * @param location - * the XContentLocation of the field - * @param fieldName - * the field name to match against this {@link ParseField} - * @param deprecationHandler called if {@code fieldName} is deprecated - * @return true if fieldName matches any of the acceptable - * names for this {@link ParseField}. - */ - public boolean match(String parserName, Supplier location, String fieldName, DeprecationHandler deprecationHandler) { Objects.requireNonNull(fieldName, "fieldName cannot be null"); // if this parse field has not been completely deprecated then try to // match the preferred name @@ -145,11 +127,11 @@ public boolean match(String parserName, Supplier location, Str for (String depName : deprecatedNames) { if (fieldName.equals(depName)) { if (fullyDeprecated) { - deprecationHandler.usedDeprecatedField(parserName, location, fieldName); + deprecationHandler.usedDeprecatedField(fieldName); } else if (allReplacedWith == null) { - deprecationHandler.usedDeprecatedName(parserName, location, fieldName, name); + deprecationHandler.usedDeprecatedName(fieldName, name); } else { - deprecationHandler.usedDeprecatedField(parserName, location, fieldName, allReplacedWith); + deprecationHandler.usedDeprecatedField(fieldName, allReplacedWith); } return true; } diff --git a/libs/x-content/src/main/java/org/elasticsearch/common/xcontent/DeprecationHandler.java b/libs/x-content/src/main/java/org/elasticsearch/common/xcontent/DeprecationHandler.java index 65f52943f0b86..2cfda82eb4c48 100644 --- a/libs/x-content/src/main/java/org/elasticsearch/common/xcontent/DeprecationHandler.java +++ b/libs/x-content/src/main/java/org/elasticsearch/common/xcontent/DeprecationHandler.java @@ -19,8 +19,6 @@ package org.elasticsearch.common.xcontent; -import java.util.function.Supplier; - /** * Callback for notifying the creator of the {@link XContentParser} that * parsing hit a deprecated field. @@ -34,35 +32,20 @@ public interface DeprecationHandler { */ DeprecationHandler THROW_UNSUPPORTED_OPERATION = new DeprecationHandler() { @Override - public void usedDeprecatedField(String parserName, Supplier location, String usedName, String replacedWith) { - if (parserName != null) { - throw new UnsupportedOperationException("deprecated fields not supported in [" + parserName + "] but got [" - + usedName + "] at [" + location.get() + "] which is a deprecated name for [" + replacedWith + "]"); - } else { - throw new UnsupportedOperationException("deprecated fields not supported here but got [" - + usedName + "] which is a deprecated name for [" + replacedWith + "]"); - } + public void usedDeprecatedField(String usedName, String replacedWith) { + throw new UnsupportedOperationException("deprecated fields not supported here but got [" + + usedName + "] which is a deprecated name for [" + replacedWith + "]"); } @Override - public void usedDeprecatedName(String parserName, Supplier location, String usedName, String modernName) { - if (parserName != null) { - throw new UnsupportedOperationException("deprecated fields not supported in [" + parserName + "] but got [" - + usedName + "] at [" + location.get() + "] which has been replaced with [" + modernName + "]"); - } else { - throw new UnsupportedOperationException("deprecated fields not supported here but got [" - + usedName + "] which has been replaced with [" + modernName + "]"); - } + public void usedDeprecatedName(String usedName, String modernName) { + throw new UnsupportedOperationException("deprecated fields not supported here but got [" + + usedName + "] which has been replaced with [" + modernName + "]"); } @Override - public void usedDeprecatedField(String parserName, Supplier location, String usedName) { - if (parserName != null) { - throw new UnsupportedOperationException("deprecated fields not supported in [" + parserName + "] but got [" - + usedName + "] at [" + location.get() + "] which has been deprecated entirely"); - } else { - throw new UnsupportedOperationException("deprecated fields not supported here but got [" - + usedName + "] which has been deprecated entirely"); - } + public void usedDeprecatedField(String usedName) { + throw new UnsupportedOperationException("deprecated fields not supported here but got [" + + usedName + "] which has been deprecated entirely"); } }; @@ -71,17 +54,17 @@ public void usedDeprecatedField(String parserName, Supplier lo */ DeprecationHandler IGNORE_DEPRECATIONS = new DeprecationHandler() { @Override - public void usedDeprecatedName(String parserName, Supplier location, String usedName, String modernName) { + public void usedDeprecatedName(String usedName, String modernName) { } @Override - public void usedDeprecatedField(String parserName, Supplier location, String usedName, String replacedWith) { + public void usedDeprecatedField(String usedName, String replacedWith) { } @Override - public void usedDeprecatedField(String parserName, Supplier location, String usedName) { + public void usedDeprecatedField(String usedName) { } }; @@ -91,7 +74,7 @@ public void usedDeprecatedField(String parserName, Supplier lo * @param usedName the provided field name * @param modernName the modern name for the field */ - void usedDeprecatedName(String parserName, Supplier location, String usedName, String modernName); + void usedDeprecatedName(String usedName, String modernName); /** * Called when the provided field name matches the current field but the entire @@ -99,13 +82,12 @@ public void usedDeprecatedField(String parserName, Supplier lo * @param usedName the provided field name * @param replacedWith the name of the field that replaced this field */ - void usedDeprecatedField(String parserName, Supplier location, String usedName, String replacedWith); + void usedDeprecatedField(String usedName, String replacedWith); /** * Called when the provided field name matches the current field but the entire * field has been marked as deprecated with no replacement * @param usedName the provided field name */ - void usedDeprecatedField(String parserName, Supplier location, String usedName); - + void usedDeprecatedField(String usedName); } diff --git a/libs/x-content/src/main/java/org/elasticsearch/common/xcontent/ObjectParser.java b/libs/x-content/src/main/java/org/elasticsearch/common/xcontent/ObjectParser.java index 73bbf812f598c..b11f6afd4bb26 100644 --- a/libs/x-content/src/main/java/org/elasticsearch/common/xcontent/ObjectParser.java +++ b/libs/x-content/src/main/java/org/elasticsearch/common/xcontent/ObjectParser.java @@ -571,7 +571,7 @@ private class FieldParser { } void assertSupports(String parserName, XContentParser parser, String currentFieldName) { - if (parseField.match(parserName, parser::getTokenLocation, currentFieldName, parser.getDeprecationHandler()) == false) { + if (parseField.match(currentFieldName, parser.getDeprecationHandler()) == false) { throw new XContentParseException(parser.getTokenLocation(), "[" + parserName + "] parsefield doesn't accept: " + currentFieldName); } diff --git a/libs/x-content/src/main/java/org/elasticsearch/common/xcontent/XContentLocation.java b/libs/x-content/src/main/java/org/elasticsearch/common/xcontent/XContentLocation.java index 1d5bfd6c2c429..43ab7503cd1dd 100644 --- a/libs/x-content/src/main/java/org/elasticsearch/common/xcontent/XContentLocation.java +++ b/libs/x-content/src/main/java/org/elasticsearch/common/xcontent/XContentLocation.java @@ -25,10 +25,7 @@ * position of a parsing error to end users and consequently have line and * column numbers starting from 1. */ -public final class XContentLocation { - - public static final XContentLocation UNKNOWN = new XContentLocation(-1, -1); - +public class XContentLocation { public final int lineNumber; public final int columnNumber; diff --git a/libs/x-content/src/test/java/org/elasticsearch/common/ParseFieldTests.java b/libs/x-content/src/test/java/org/elasticsearch/common/ParseFieldTests.java index e7420356c8fac..381c7c3e959be 100644 --- a/libs/x-content/src/test/java/org/elasticsearch/common/ParseFieldTests.java +++ b/libs/x-content/src/test/java/org/elasticsearch/common/ParseFieldTests.java @@ -66,11 +66,11 @@ public void testDeprecatedWithNoReplacement() { ParseField field = new ParseField(name).withDeprecation(alternatives).withAllDeprecated(); assertFalse(field.match("not a field name", LoggingDeprecationHandler.INSTANCE)); assertTrue(field.match("dep", LoggingDeprecationHandler.INSTANCE)); - assertWarnings("Deprecated field [dep] used, this field is unused and will be removed entirely"); + assertWarnings("Deprecated field [dep] used, which has been removed entirely"); assertTrue(field.match("old_dep", LoggingDeprecationHandler.INSTANCE)); - assertWarnings("Deprecated field [old_dep] used, this field is unused and will be removed entirely"); + assertWarnings("Deprecated field [old_dep] used, which has been removed entirely"); assertTrue(field.match("new_dep", LoggingDeprecationHandler.INSTANCE)); - assertWarnings("Deprecated field [new_dep] used, this field is unused and will be removed entirely"); + assertWarnings("Deprecated field [new_dep] used, which has been removed entirely"); } diff --git a/libs/x-content/src/test/java/org/elasticsearch/common/xcontent/ObjectParserTests.java b/libs/x-content/src/test/java/org/elasticsearch/common/xcontent/ObjectParserTests.java index 9a813c8a24616..c99d1b10d6a4d 100644 --- a/libs/x-content/src/test/java/org/elasticsearch/common/xcontent/ObjectParserTests.java +++ b/libs/x-content/src/test/java/org/elasticsearch/common/xcontent/ObjectParserTests.java @@ -223,7 +223,7 @@ class TestStruct { objectParser.declareField((i, v, c) -> v.test = i.text(), new ParseField("test", "old_test"), ObjectParser.ValueType.STRING); objectParser.parse(parser, s, null); assertEquals("foo", s.test); - assertWarnings("[foo][1:15] Deprecated field [old_test] used, expected [test] instead"); + assertWarnings("Deprecated field [old_test] used, expected [test] instead"); } public void testFailOnValueType() throws IOException { diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ScriptProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ScriptProcessorFactoryTests.java index c7018d40b18ca..9559c150df68a 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ScriptProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ScriptProcessorFactoryTests.java @@ -98,7 +98,7 @@ public void testInlineBackcompat() throws Exception { configMap.put("inline", "code"); factory.create(null, randomAlphaOfLength(10), configMap); - assertWarnings("[script][1:11] Deprecated field [inline] used, expected [source] instead"); + assertWarnings("Deprecated field [inline] used, expected [source] instead"); } public void testFactoryInvalidateWithInvalidCompiledScript() throws Exception { diff --git a/server/src/main/java/org/elasticsearch/common/xcontent/LoggingDeprecationHandler.java b/server/src/main/java/org/elasticsearch/common/xcontent/LoggingDeprecationHandler.java index 5feca4bfaab5a..9a885b55d146c 100644 --- a/server/src/main/java/org/elasticsearch/common/xcontent/LoggingDeprecationHandler.java +++ b/server/src/main/java/org/elasticsearch/common/xcontent/LoggingDeprecationHandler.java @@ -23,8 +23,6 @@ import org.elasticsearch.common.ParseField; import org.elasticsearch.common.logging.DeprecationLogger; -import java.util.function.Supplier; - /** * Logs deprecations to the {@link DeprecationLogger}. *

@@ -51,23 +49,17 @@ private LoggingDeprecationHandler() { } @Override - public void usedDeprecatedName(String parserName, Supplier location, String usedName, String modernName) { - String prefix = parserName == null ? "" : "[" + parserName + "][" + location.get() + "] "; - deprecationLogger.deprecated("{}Deprecated field [{}] used, expected [{}] instead", - prefix, usedName, modernName); + public void usedDeprecatedName(String usedName, String modernName) { + deprecationLogger.deprecated("Deprecated field [{}] used, expected [{}] instead", usedName, modernName); } @Override - public void usedDeprecatedField(String parserName, Supplier location, String usedName, String replacedWith) { - String prefix = parserName == null ? "" : "[" + parserName + "][" + location.get() + "] "; - deprecationLogger.deprecated("{}Deprecated field [{}] used, replaced by [{}]", - prefix, usedName, replacedWith); + public void usedDeprecatedField(String usedName, String replacedWith) { + deprecationLogger.deprecated("Deprecated field [{}] used, replaced by [{}]", usedName, replacedWith); } @Override - public void usedDeprecatedField(String parserName, Supplier location, String usedName) { - String prefix = parserName == null ? "" : "[" + parserName + "][" + location.get() + "] "; - deprecationLogger.deprecated("{}Deprecated field [{}] used, this field is unused and will be removed entirely", - prefix, usedName); + public void usedDeprecatedField(String usedName) { + deprecationLogger.deprecated("Deprecated field [{}] used, which has been removed entirely", usedName); } } diff --git a/server/src/test/java/org/elasticsearch/index/query/BoolQueryBuilderTests.java b/server/src/test/java/org/elasticsearch/index/query/BoolQueryBuilderTests.java index 03916bac58a84..93d46ed592570 100644 --- a/server/src/test/java/org/elasticsearch/index/query/BoolQueryBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/index/query/BoolQueryBuilderTests.java @@ -302,7 +302,7 @@ public void testDeprecation() throws IOException { QueryBuilder q = parseQuery(query); QueryBuilder expected = new BoolQueryBuilder().mustNot(new MatchAllQueryBuilder()); assertEquals(expected, q); - assertWarnings("[bool][1:24] Deprecated field [mustNot] used, expected [must_not] instead"); + assertWarnings("Deprecated field [mustNot] used, expected [must_not] instead"); } public void testRewrite() throws IOException { diff --git a/server/src/test/java/org/elasticsearch/script/StoredScriptTests.java b/server/src/test/java/org/elasticsearch/script/StoredScriptTests.java index 47dc7aaae2a3b..627d67dc833e4 100644 --- a/server/src/test/java/org/elasticsearch/script/StoredScriptTests.java +++ b/server/src/test/java/org/elasticsearch/script/StoredScriptTests.java @@ -104,7 +104,7 @@ public void testSourceParsing() throws Exception { assertThat(parsed, equalTo(source)); } - assertWarnings("[stored script source][1:33] Deprecated field [code] used, expected [source] instead"); + assertWarnings("Deprecated field [code] used, expected [source] instead"); // complex script with script object and empty options try (XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON)) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/utils/LoggingDeprecationAccumulationHandler.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/utils/LoggingDeprecationAccumulationHandler.java index 323e3a84cdf2e..5e2a4d7a25302 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/utils/LoggingDeprecationAccumulationHandler.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/utils/LoggingDeprecationAccumulationHandler.java @@ -8,12 +8,10 @@ import org.elasticsearch.common.logging.LoggerMessageFormat; import org.elasticsearch.common.xcontent.DeprecationHandler; import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; -import org.elasticsearch.common.xcontent.XContentLocation; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.function.Supplier; /** * Very similar to {@link org.elasticsearch.common.xcontent.LoggingDeprecationHandler} main differences are: @@ -28,27 +26,24 @@ public class LoggingDeprecationAccumulationHandler implements DeprecationHandler private final List deprecations = new ArrayList<>(); @Override - public void usedDeprecatedName(String parserName, Supplier location, String usedName, String modernName) { - LoggingDeprecationHandler.INSTANCE.usedDeprecatedName(parserName, location, usedName, modernName); - String prefix = parserName == null ? "" : "[" + parserName + "][" + location.get() + "] "; - deprecations.add(LoggerMessageFormat.format("{}Deprecated field [{}] used, expected [{}] instead", - new Object[]{prefix, usedName, modernName})); + public void usedDeprecatedName(String usedName, String modernName) { + LoggingDeprecationHandler.INSTANCE.usedDeprecatedName(usedName, modernName); + deprecations.add(LoggerMessageFormat.format("Deprecated field [{}] used, expected [{}] instead", + new Object[] {usedName, modernName})); } @Override - public void usedDeprecatedField(String parserName, Supplier location, String usedName, String replacedWith) { - LoggingDeprecationHandler.INSTANCE.usedDeprecatedField(parserName, location, usedName, replacedWith); - String prefix = parserName == null ? "" : "[" + parserName + "][" + location.get() + "] "; - deprecations.add(LoggerMessageFormat.format("{}Deprecated field [{}] used, replaced by [{}]", - new Object[]{prefix, usedName, replacedWith})); + public void usedDeprecatedField(String usedName, String replacedWith) { + LoggingDeprecationHandler.INSTANCE.usedDeprecatedField(usedName, replacedWith); + deprecations.add(LoggerMessageFormat.format("Deprecated field [{}] used, replaced by [{}]", + new Object[] {usedName, replacedWith})); } @Override - public void usedDeprecatedField(String parserName, Supplier location, String usedName) { - LoggingDeprecationHandler.INSTANCE.usedDeprecatedField(parserName, location, usedName); - String prefix = parserName == null ? "" : "[" + parserName + "][" + location.get() + "] "; - deprecations.add(LoggerMessageFormat.format("{}Deprecated field [{}] used, unused and will be removed entirely", - new Object[]{prefix, usedName})); + public void usedDeprecatedField(String usedName) { + LoggingDeprecationHandler.INSTANCE.usedDeprecatedField(usedName); + deprecations.add(LoggerMessageFormat.format("Deprecated field [{}] used, which has been deprecated entirely", + new Object[]{ usedName })); } /** diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/utils/XContentObjectTransformerTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/utils/XContentObjectTransformerTests.java index 886602395238f..d6ebc9a2e150b 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/utils/XContentObjectTransformerTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/utils/XContentObjectTransformerTests.java @@ -127,8 +127,8 @@ public void testToMap() throws IOException { public void testDeprecationWarnings() throws IOException { XContentObjectTransformer queryBuilderTransformer = new XContentObjectTransformer<>(NamedXContentRegistry.EMPTY, (p)-> { - p.getDeprecationHandler().usedDeprecatedField(null, null, "oldField", "newField"); - p.getDeprecationHandler().usedDeprecatedName(null, null, "oldName", "modernName"); + p.getDeprecationHandler().usedDeprecatedField("oldField", "newField"); + p.getDeprecationHandler().usedDeprecatedName("oldName", "modernName"); return new BoolQueryBuilder(); }); List deprecations = new ArrayList<>(); diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ingest/InferenceProcessor.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ingest/InferenceProcessor.java index b52b8b5b64e3f..2a4861c5247f7 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ingest/InferenceProcessor.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ingest/InferenceProcessor.java @@ -242,7 +242,7 @@ public InferenceProcessor create(Map processorFactori fieldMap = ConfigurationUtils.readOptionalMap(TYPE, tag, config, FIELD_MAPPINGS); //TODO Remove in 8.x if (fieldMap != null) { - LoggingDeprecationHandler.INSTANCE.usedDeprecatedName(null, () -> null, FIELD_MAPPINGS, FIELD_MAP); + LoggingDeprecationHandler.INSTANCE.usedDeprecatedName(FIELD_MAPPINGS, FIELD_MAP); } } InferenceConfig inferenceConfig = inferenceConfigFromMap(ConfigurationUtils.readMap(TYPE, tag, config, INFERENCE_CONFIG)); diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ApiKeyService.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ApiKeyService.java index c363ad1253509..f36ce90660a23 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ApiKeyService.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ApiKeyService.java @@ -49,7 +49,6 @@ import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.common.xcontent.XContentLocation; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.query.BoolQueryBuilder; @@ -619,25 +618,21 @@ private ApiKeyLoggingDeprecationHandler(DeprecationLogger logger, String apiKeyI } @Override - public void usedDeprecatedName(String parserName, Supplier location, String usedName, String modernName) { - String prefix = parserName == null ? "" : "[" + parserName + "][" + location.get() + "] "; - deprecationLogger.deprecated("{}Deprecated field [{}] used in api key [{}], expected [{}] instead", - prefix, usedName, apiKeyId, modernName); + public void usedDeprecatedName(String usedName, String modernName) { + deprecationLogger.deprecated("Deprecated field [{}] used in api key [{}], expected [{}] instead", + usedName, apiKeyId, modernName); } @Override - public void usedDeprecatedField(String parserName, Supplier location, String usedName, String replacedWith) { - String prefix = parserName == null ? "" : "[" + parserName + "][" + location.get() + "] "; - deprecationLogger.deprecated("{}Deprecated field [{}] used in api key [{}], replaced by [{}]", - prefix, usedName, apiKeyId, replacedWith); + public void usedDeprecatedField(String usedName, String replacedWith) { + deprecationLogger.deprecated("Deprecated field [{}] used in api key [{}], replaced by [{}]", + usedName, apiKeyId, replacedWith); } @Override - public void usedDeprecatedField(String parserName, Supplier location, String usedName) { - String prefix = parserName == null ? "" : "[" + parserName + "][" + location.get() + "] "; - deprecationLogger.deprecated( - "{}Deprecated field [{}] used in api key [{}], which is unused and will be removed entirely", - prefix, usedName); + public void usedDeprecatedField(String usedName) { + deprecationLogger.deprecated("Deprecated field [{}] used in api key [{}], which has been removed entirely", + usedName); } } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/ml/data_frame_analytics_crud.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/ml/data_frame_analytics_crud.yml index c5df3d9f6cc51..a5a99b30391ea 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/ml/data_frame_analytics_crud.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/ml/data_frame_analytics_crud.yml @@ -1869,7 +1869,7 @@ setup: - do: allowed_warnings: - - '[classification][1:139] Deprecated field [maximum_number_trees] used, expected [max_trees] instead' + - 'Deprecated field [maximum_number_trees] used, expected [max_trees] instead' ml.put_data_frame_analytics: id: "classification-with-maximum-number-trees" body: >