diff --git a/plugin/core/src/main/java/org/elasticsearch/license/SelfGeneratedLicense.java b/plugin/core/src/main/java/org/elasticsearch/license/SelfGeneratedLicense.java index f791d8b15a3..5323ff5b79e 100644 --- a/plugin/core/src/main/java/org/elasticsearch/license/SelfGeneratedLicense.java +++ b/plugin/core/src/main/java/org/elasticsearch/license/SelfGeneratedLicense.java @@ -6,6 +6,7 @@ package org.elasticsearch.license; import org.elasticsearch.common.bytes.BytesReference; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -56,8 +57,8 @@ class SelfGeneratedLicense { byteBuffer.get(content); final License expectedLicense; // EMPTY is safe here because we don't call namedObject - try (XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser(NamedXContentRegistry.EMPTY, - decrypt(content))) { + try (XContentParser parser = XContentFactory.xContent(XContentType.JSON) + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, decrypt(content))) { parser.nextToken(); expectedLicense = License.builder().fromLicenseSpec(License.fromXContent(parser), license.signature()).version(-version).build(); diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/accesscontrol/SecurityIndexSearcherWrapper.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/accesscontrol/SecurityIndexSearcherWrapper.java index a18913db7c5..fb6a0f6b9c6 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/accesscontrol/SecurityIndexSearcherWrapper.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/accesscontrol/SecurityIndexSearcherWrapper.java @@ -33,6 +33,7 @@ import org.elasticsearch.common.logging.LoggerMessageFormat; import org.elasticsearch.common.logging.ServerLoggers; import org.elasticsearch.common.lucene.search.Queries; import org.elasticsearch.common.util.concurrent.ThreadContext; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; @@ -131,7 +132,7 @@ public class SecurityIndexSearcherWrapper extends IndexSearcherWrapper { QueryShardContext queryShardContext = queryShardContextProvider.apply(shardId); String templateResult = evaluateTemplate(bytesReference.utf8ToString()); try (XContentParser parser = XContentFactory.xContent(templateResult) - .createParser(queryShardContext.getXContentRegistry(), templateResult)) { + .createParser(queryShardContext.getXContentRegistry(), LoggingDeprecationHandler.INSTANCE, templateResult)) { QueryBuilder queryBuilder = queryShardContext.parseInnerQueryBuilder(parser); verifyRoleQuery(queryBuilder); failIfQueryUsesClient(queryBuilder, queryShardContext); @@ -249,7 +250,8 @@ public class SecurityIndexSearcherWrapper extends IndexSearcherWrapper { String evaluateTemplate(String querySource) throws IOException { // EMPTY is safe here because we never use namedObject - try (XContentParser parser = XContentFactory.xContent(querySource).createParser(NamedXContentRegistry.EMPTY, querySource)) { + try (XContentParser parser = XContentFactory.xContent(querySource).createParser(NamedXContentRegistry.EMPTY, + LoggingDeprecationHandler.INSTANCE, querySource)) { XContentParser.Token token = parser.nextToken(); if (token != XContentParser.Token.START_OBJECT) { throw new ElasticsearchParseException("Unexpected token [" + token + "]"); diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/CertificateGenerateTool.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/CertificateGenerateTool.java index f08aab25101..aa59c9c72ae 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/CertificateGenerateTool.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/CertificateGenerateTool.java @@ -27,6 +27,7 @@ import org.elasticsearch.common.io.PathUtils; import org.elasticsearch.common.network.InetAddresses; import org.elasticsearch.common.util.set.Sets; import org.elasticsearch.common.xcontent.ConstructingObjectParser; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.ObjectParser; import org.elasticsearch.common.xcontent.XContentParser; @@ -301,7 +302,8 @@ public class CertificateGenerateTool extends EnvironmentAwareCommand { static Collection parseFile(Path file) throws Exception { try (Reader reader = Files.newBufferedReader(file)) { // EMPTY is safe here because we never use namedObject - XContentParser xContentParser = XContentType.YAML.xContent().createParser(NamedXContentRegistry.EMPTY, reader); + XContentParser xContentParser = XContentType.YAML.xContent() + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, reader); return InputFileParser.PARSER.parse(xContentParser, new ArrayList<>(), null); } } diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/CertificateTool.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/CertificateTool.java index 1ef37cfdedf..654119afba9 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/CertificateTool.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/CertificateTool.java @@ -32,6 +32,7 @@ import org.elasticsearch.common.io.PathUtils; import org.elasticsearch.common.network.InetAddresses; import org.elasticsearch.common.util.set.Sets; import org.elasticsearch.common.xcontent.ConstructingObjectParser; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.ObjectParser; import org.elasticsearch.common.xcontent.XContentParser; @@ -907,7 +908,8 @@ public class CertificateTool extends LoggingAwareMultiCommand { static Collection parseFile(Path file) throws Exception { try (Reader reader = Files.newBufferedReader(file)) { // EMPTY is safe here because we never use namedObject - XContentParser xContentParser = XContentType.YAML.xContent().createParser(NamedXContentRegistry.EMPTY, reader); + XContentParser xContentParser = XContentType.YAML.xContent() + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, reader); return CertificateToolParser.PARSER.parse(xContentParser, new ArrayList<>(), null); } } diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/TemplateUtils.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/TemplateUtils.java index b936b0969c2..0e2c57dbb45 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/TemplateUtils.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/TemplateUtils.java @@ -17,6 +17,7 @@ import org.elasticsearch.common.collect.ImmutableOpenMap; import org.elasticsearch.common.compress.CompressedXContent; import org.elasticsearch.common.compress.NotXContentException; import org.elasticsearch.common.io.Streams; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentHelper; @@ -45,7 +46,8 @@ public class TemplateUtils { public static void loadTemplateIntoMap(String resource, Map map, String templateName, String version, String versionProperty, Logger logger) { final String template = loadTemplate(resource, version, versionProperty); - try (XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser(NamedXContentRegistry.EMPTY, template)) { + try (XContentParser parser = XContentFactory.xContent(XContentType.JSON) + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, template)) { map.put(templateName, IndexTemplateMetaData.Builder.fromXContent(parser, templateName)); } catch (IOException e) { // TODO: should we handle this with a thrown exception? diff --git a/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedConfigTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedConfigTests.java index 58282667096..a3f74d25531 100644 --- a/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedConfigTests.java +++ b/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedConfigTests.java @@ -11,6 +11,8 @@ import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.common.xcontent.DeprecationHandler; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; @@ -151,14 +153,16 @@ public class DatafeedConfigTests extends AbstractSerializingTestCase DatafeedConfig.CONFIG_PARSER.apply(parser, null).build()); assertEquals("[datafeed_config] unknown field [tomorrows_technology_today], parser not found", e.getMessage()); } public void testFutureMetadataParse() throws IOException { - XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser(NamedXContentRegistry.EMPTY, FUTURE_DATAFEED); + XContentParser parser = XContentFactory.xContent(XContentType.JSON) + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, FUTURE_DATAFEED); // Unlike the config version of this test, the metadata parser should tolerate the unknown future field assertNotNull(DatafeedConfig.METADATA_PARSER.apply(parser, null).build()); } diff --git a/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/config/AnalysisLimitsTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/config/AnalysisLimitsTests.java index 5dba5ae2519..6c6e08e6269 100644 --- a/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/config/AnalysisLimitsTests.java +++ b/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/config/AnalysisLimitsTests.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.core.ml.job.config; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.common.xcontent.DeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; @@ -44,21 +45,24 @@ public class AnalysisLimitsTests extends AbstractSerializingTestCase AnalysisLimits.CONFIG_PARSER.apply(parser, null)); assertThat(e.getRootCause().getMessage(), containsString("model_memory_limit must be at least 1 MiB. Value = -1")); } public void testParseModelMemoryLimitGivenZero() throws IOException { String json = "{\"model_memory_limit\": 0}"; - XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser(NamedXContentRegistry.EMPTY, json); + XContentParser parser = XContentFactory.xContent(XContentType.JSON) + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, json); ParsingException e = expectThrows(ParsingException.class, () -> AnalysisLimits.CONFIG_PARSER.apply(parser, null)); assertThat(e.getRootCause().getMessage(), containsString("model_memory_limit must be at least 1 MiB. Value = 0")); } public void testParseModelMemoryLimitGivenPositiveNumber() throws IOException { String json = "{\"model_memory_limit\": 2048}"; - XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser(NamedXContentRegistry.EMPTY, json); + XContentParser parser = XContentFactory.xContent(XContentType.JSON) + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, json); AnalysisLimits limits = AnalysisLimits.CONFIG_PARSER.apply(parser, null); @@ -67,28 +71,32 @@ public class AnalysisLimitsTests extends AbstractSerializingTestCase AnalysisLimits.CONFIG_PARSER.apply(parser, null)); assertThat(e.getRootCause().getMessage(), containsString("Values less than -1 bytes are not supported: -4mb")); } public void testParseModelMemoryLimitGivenZeroString() throws IOException { String json = "{\"model_memory_limit\":\"0MB\"}"; - XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser(NamedXContentRegistry.EMPTY, json); + XContentParser parser = XContentFactory.xContent(XContentType.JSON) + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, json); ParsingException e = expectThrows(ParsingException.class, () -> AnalysisLimits.CONFIG_PARSER.apply(parser, null)); assertThat(e.getRootCause().getMessage(), containsString("model_memory_limit must be at least 1 MiB. Value = 0")); } public void testParseModelMemoryLimitGivenLessThanOneMBString() throws IOException { String json = "{\"model_memory_limit\":\"1000Kb\"}"; - XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser(NamedXContentRegistry.EMPTY, json); + XContentParser parser = XContentFactory.xContent(XContentType.JSON) + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, json); ParsingException e = expectThrows(ParsingException.class, () -> AnalysisLimits.CONFIG_PARSER.apply(parser, null)); assertThat(e.getRootCause().getMessage(), containsString("model_memory_limit must be at least 1 MiB. Value = 0")); } public void testParseModelMemoryLimitGivenStringMultipleOfMBs() throws IOException { String json = "{\"model_memory_limit\":\"4g\"}"; - XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser(NamedXContentRegistry.EMPTY, json); + XContentParser parser = XContentFactory.xContent(XContentType.JSON) + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, json); AnalysisLimits limits = AnalysisLimits.CONFIG_PARSER.apply(parser, null); @@ -97,7 +105,8 @@ public class AnalysisLimitsTests extends AbstractSerializingTestCase { } public void testFutureConfigParse() throws IOException { - XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser(NamedXContentRegistry.EMPTY, FUTURE_JOB); + XContentParser parser = XContentFactory.xContent(XContentType.JSON) + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, FUTURE_JOB); IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> Job.CONFIG_PARSER.apply(parser, null).build()); assertEquals("[job_details] unknown field [tomorrows_technology_today], parser not found", e.getMessage()); } public void testFutureMetadataParse() throws IOException { - XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser(NamedXContentRegistry.EMPTY, FUTURE_JOB); + XContentParser parser = XContentFactory.xContent(XContentType.JSON) + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, FUTURE_JOB); // Unlike the config version of this test, the metadata parser should tolerate the unknown future field assertNotNull(Job.METADATA_PARSER.apply(parser, null).build()); } diff --git a/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutodetectResultsParser.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutodetectResultsParser.java index 9c065009f95..f4a08651340 100644 --- a/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutodetectResultsParser.java +++ b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutodetectResultsParser.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.ml.job.process.autodetect.output; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; @@ -33,7 +34,8 @@ public class AutodetectResultsParser extends AbstractComponent { public Iterator parseResults(InputStream in) throws ElasticsearchParseException { try { - XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser(NamedXContentRegistry.EMPTY, in); + XContentParser parser = XContentFactory.xContent(XContentType.JSON) + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, in); XContentParser.Token token = parser.nextToken(); // if start of an array ignore it, we expect an array of results if (token != XContentParser.Token.START_ARRAY) { diff --git a/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/JsonDataToProcessWriter.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/JsonDataToProcessWriter.java index eae7385269e..15a162c6a3c 100644 --- a/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/JsonDataToProcessWriter.java +++ b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/JsonDataToProcessWriter.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.ml.job.process.autodetect.writer; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; import org.elasticsearch.common.logging.Loggers; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; @@ -79,7 +80,7 @@ class JsonDataToProcessWriter extends AbstractDataToProcessWriter { private void writeJsonXContent(CategorizationAnalyzer categorizationAnalyzer, InputStream inputStream) throws IOException { try (XContentParser parser = XContentFactory.xContent(XContentType.JSON) - .createParser(xContentRegistry, inputStream)) { + .createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, inputStream)) { writeJson(categorizationAnalyzer, parser); } } @@ -91,7 +92,7 @@ class JsonDataToProcessWriter extends AbstractDataToProcessWriter { break; } try (XContentParser parser = XContentFactory.xContent(XContentType.SMILE) - .createParser(xContentRegistry, nextObject)) { + .createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, nextObject)) { writeJson(categorizationAnalyzer, parser); } } diff --git a/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/XContentRecordReaderTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/XContentRecordReaderTests.java index 84928b03f20..c6b91f86bf2 100644 --- a/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/XContentRecordReaderTests.java +++ b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/XContentRecordReaderTests.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.ml.job.process.autodetect.writer; import com.fasterxml.jackson.core.JsonParseException; import org.apache.logging.log4j.Logger; import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.common.xcontent.DeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; @@ -228,7 +229,8 @@ public class XContentRecordReaderTests extends ESTestCase { InputStream inputStream2 = new CountingInputStream(inputStream, mock(DataCountsReporter.class)); return XContentFactory.xContent(XContentType.JSON) - .createParser(new NamedXContentRegistry(Collections.emptyList()), inputStream2); + .createParser(new NamedXContentRegistry(Collections.emptyList()), + DeprecationHandler.THROW_UNSUPPORTED_OPERATION, inputStream2); } private Map createFieldMap() { diff --git a/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/logging/CppLogMessageTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/logging/CppLogMessageTests.java index 432dbb51451..d3145bb9f6c 100644 --- a/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/logging/CppLogMessageTests.java +++ b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/logging/CppLogMessageTests.java @@ -6,6 +6,7 @@ package org.elasticsearch.xpack.ml.job.process.logging; import org.elasticsearch.common.io.stream.Writeable.Reader; +import org.elasticsearch.common.xcontent.DeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContent; import org.elasticsearch.common.xcontent.XContentFactory; @@ -39,7 +40,7 @@ public class CppLogMessageTests extends AbstractSerializingTestCase existingUsers = new HashSet<>(); String allUsersJson = postURL(settings, env, "GET", this.url.value(options) + "/_xpack/security/user/", options, null); // EMPTY is safe here because we never use namedObject - try (XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, allUsersJson)) { + try (XContentParser parser = JsonXContent.jsonXContent + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, allUsersJson)) { XContentParser.Token token = parser.nextToken(); String userName; if (token == XContentParser.Token.START_OBJECT) { @@ -287,7 +289,8 @@ public class ESNativeRealmMigrateTool extends LoggingAwareMultiCommand { Set existingRoles = new HashSet<>(); String allRolesJson = postURL(settings, env, "GET", this.url.value(options) + "/_xpack/security/role/", options, null); // EMPTY is safe here because we never use namedObject - try (XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, allRolesJson)) { + try (XContentParser parser = JsonXContent.jsonXContent + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, allRolesJson)) { XContentParser.Token token = parser.nextToken(); String roleName; if (token == XContentParser.Token.START_OBJECT) { diff --git a/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java index 84ece7bf655..f9c5e8a90de 100644 --- a/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java @@ -12,6 +12,7 @@ import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.yaml.YamlXContent; @@ -207,7 +208,8 @@ public class FileRolesStore extends AbstractComponent { String roleName = null; try { // EMPTY is safe here because we never use namedObject - XContentParser parser = YamlXContent.yamlXContent.createParser(NamedXContentRegistry.EMPTY, segment); + XContentParser parser = YamlXContent.yamlXContent + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, segment); XContentParser.Token token = parser.nextToken(); if (token == XContentParser.Token.START_OBJECT) { token = parser.nextToken(); diff --git a/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/tool/SetupPasswordToolTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/tool/SetupPasswordToolTests.java index 123713e0799..fbaa3ba04a9 100644 --- a/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/tool/SetupPasswordToolTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/tool/SetupPasswordToolTests.java @@ -16,6 +16,7 @@ import org.elasticsearch.common.CheckedSupplier; import org.elasticsearch.common.settings.KeyStoreWrapper; import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.xcontent.DeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -418,7 +419,8 @@ public class SetupPasswordToolTests extends CommandTestCase { } private String parsePassword(String value) throws IOException { - try (XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, value)) { + try (XContentParser parser = JsonXContent.jsonXContent + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, value)) { XContentParser.Token token = parser.nextToken(); if (token == XContentParser.Token.START_OBJECT) { if (parser.nextToken() == XContentParser.Token.FIELD_NAME) { diff --git a/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/ExpressionRoleMappingTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/ExpressionRoleMappingTests.java index 0a96dd7c248..510540468a4 100644 --- a/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/ExpressionRoleMappingTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/ExpressionRoleMappingTests.java @@ -25,6 +25,7 @@ package org.elasticsearch.xpack.security.authc.support.mapper; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; +import org.elasticsearch.common.xcontent.DeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; @@ -149,7 +150,8 @@ public class ExpressionRoleMappingTests extends ESTestCase { private ExpressionRoleMapping parse(String json, String name) throws IOException { final NamedXContentRegistry registry = NamedXContentRegistry.EMPTY; - final XContentParser parser = XContentType.JSON.xContent().createParser(registry, json); + final XContentParser parser = XContentType.JSON.xContent() + .createParser(registry, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, json); final ExpressionRoleMapping mapping = ExpressionRoleMapping.parse(name, parser); assertThat(mapping, notNullValue()); assertThat(mapping.getName(), equalTo(name)); diff --git a/plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/action/oauth2/RestGetTokenActionTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/action/oauth2/RestGetTokenActionTests.java index f31834c5734..9e99d0cf156 100644 --- a/plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/action/oauth2/RestGetTokenActionTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/action/oauth2/RestGetTokenActionTests.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.security.rest.action.oauth2; import org.apache.lucene.util.SetOnce; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.common.xcontent.DeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.XContentParser; @@ -89,7 +90,8 @@ public class RestGetTokenActionTests extends ESTestCase { "\"password\": \"" + SecuritySettingsSourceField.TEST_PASSWORD + "\"," + "\"scope\": \"FULL\"" + "}"; - try (XContentParser parser = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, request)) { + try (XContentParser parser = XContentType.JSON.xContent() + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, request)) { CreateTokenRequest createTokenRequest = RestGetTokenAction.PARSER.parse(parser, null); assertEquals("password", createTokenRequest.getGrantType()); assertEquals("user1", createTokenRequest.getUsername()); @@ -105,7 +107,8 @@ public class RestGetTokenActionTests extends ESTestCase { "\"refresh_token\": \"" + token + "\"," + "\"scope\": \"FULL\"" + "}"; - try (XContentParser parser = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, request)) { + try (XContentParser parser = XContentType.JSON.xContent() + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, request)) { CreateTokenRequest createTokenRequest = RestGetTokenAction.PARSER.parse(parser, null); assertEquals("refresh_token", createTokenRequest.getGrantType()); assertEquals(token, createTokenRequest.getRefreshToken()); diff --git a/qa/ml-native-tests/src/test/java/org/elasticsearch/xpack/ml/integration/RevertModelSnapshotIT.java b/qa/ml-native-tests/src/test/java/org/elasticsearch/xpack/ml/integration/RevertModelSnapshotIT.java index f5904e9ce63..355af23ee04 100644 --- a/qa/ml-native-tests/src/test/java/org/elasticsearch/xpack/ml/integration/RevertModelSnapshotIT.java +++ b/qa/ml-native-tests/src/test/java/org/elasticsearch/xpack/ml/integration/RevertModelSnapshotIT.java @@ -7,6 +7,7 @@ package org.elasticsearch.xpack.ml.integration; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.json.JsonXContent; import org.elasticsearch.index.query.QueryBuilders; @@ -162,7 +163,8 @@ public class RevertModelSnapshotIT extends MlNativeAutodetectIntegTestCase { SearchHits hits = response.getHits(); assertThat(hits.getTotalHits(), equalTo(1L)); try { - XContentParser parser = JsonXContent.jsonXContent.createParser(null, hits.getAt(0).getSourceAsString()); + XContentParser parser = JsonXContent.jsonXContent + .createParser(null, LoggingDeprecationHandler.INSTANCE, hits.getAt(0).getSourceAsString()); return Quantiles.PARSER.apply(parser, null); } catch (IOException e) { throw new IllegalStateException(e);