From affc9e3563d9cc14e174e3ba9a95e757792e0fa5 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Wed, 14 Feb 2018 09:41:26 -0700 Subject: [PATCH] Move more XContent.createParser calls to non-deprecated version (elastic/x-pack-elasticsearch#3928) Part 2 This moves more of the callers to pass in the DeprecationHandler. Relates to elastic/x-pack-elasticsearch#28504 Original commit: elastic/x-pack-elasticsearch@e0b52bf050a14b241eb93d20701ea580bf849ef1 --- .../org/elasticsearch/license/License.java | 4 ++- .../autodetect/state/ModelSnapshot.java | 4 ++- .../user/ChangePasswordRequestBuilder.java | 4 ++- .../action/user/PutUserRequestBuilder.java | 4 ++- .../support/mapper/ExpressionRoleMapping.java | 4 ++- .../core/security/authz/RoleDescriptor.java | 7 ++++-- .../support/xcontent/XContentSource.java | 3 ++- .../ValidateJobConfigActionRequestTests.java | 3 ++- .../ml/job/config/DataDescriptionTests.java | 10 +++++--- .../ml/action/TransportGetFiltersAction.java | 6 +++-- .../persistence/BatchedBucketsIterator.java | 3 ++- .../BatchedInfluencersIterator.java | 3 ++- .../persistence/BatchedRecordsIterator.java | 3 ++- .../xpack/ml/job/persistence/JobProvider.java | 25 +++++++++++++------ .../process/logging/CppLogMessageHandler.java | 4 ++- .../output/NormalizerResultHandler.java | 4 ++- .../retention/ExpiredForecastsRemover.java | 3 ++- .../xpack/ml/notifications/AuditorTests.java | 4 ++- .../exporter/FilteredMonitoringDoc.java | 3 ++- .../exporter/BaseMonitoringDocTestCase.java | 4 ++- .../mapper/NativeRoleMappingStore.java | 4 ++- ...sportSamlInvalidateSessionActionTests.java | 4 ++- .../security/rest/RestRequestFilterTests.java | 10 +++++--- .../rest/SecurityRestFilterTests.java | 11 +++++--- .../xpack/sql/client/HttpClient.java | 3 ++- .../input/http/ExecutableHttpInput.java | 4 ++- .../attachment/ReportingAttachmentParser.java | 4 ++- .../notification/jira/JiraAccount.java | 4 ++- .../watcher/notification/jira/JiraIssue.java | 4 ++- .../notification/pagerduty/SentEvent.java | 4 ++- .../search/WatcherSearchTemplateService.java | 4 ++- .../xpack/watcher/watch/WatchParser.java | 6 +++-- .../watcher/common/http/HttpProxyTests.java | 11 ++++---- .../execution/ExecutionServiceTests.java | 5 ++-- .../watcher/input/http/HttpInputTests.java | 4 ++- .../test/integration/SearchInputTests.java | 5 ++-- .../MlNativeAutodetectIntegTestCase.java | 7 +++--- 37 files changed, 137 insertions(+), 62 deletions(-) diff --git a/plugin/core/src/main/java/org/elasticsearch/license/License.java b/plugin/core/src/main/java/org/elasticsearch/license/License.java index 646bb03550a..f1912c91c63 100644 --- a/plugin/core/src/main/java/org/elasticsearch/license/License.java +++ b/plugin/core/src/main/java/org/elasticsearch/license/License.java @@ -19,6 +19,7 @@ import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.ToXContentObject; @@ -496,7 +497,8 @@ public class License implements ToXContentObject { throw new ElasticsearchParseException("failed to parse license - no content-type provided"); } // EMPTY is safe here because we don't call namedObject - final XContentParser parser = xContentType.xContent().createParser(NamedXContentRegistry.EMPTY, bytes); + final XContentParser parser = xContentType.xContent() + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, bytes); License license = null; if (parser.nextToken() == XContentParser.Token.START_OBJECT) { if (parser.nextToken() == XContentParser.Token.FIELD_NAME) { diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSnapshot.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSnapshot.java index a4ddb27cb9e..0d5ed7ad72b 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSnapshot.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSnapshot.java @@ -11,6 +11,7 @@ import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.ObjectParser; import org.elasticsearch.common.xcontent.ObjectParser.ValueType; @@ -307,7 +308,8 @@ public class ModelSnapshot implements ToXContentObject, Writeable { } public static ModelSnapshot fromJson(BytesReference bytesReference) { - try (XContentParser parser = XContentFactory.xContent(bytesReference).createParser(NamedXContentRegistry.EMPTY, bytesReference)) { + try (XContentParser parser = XContentFactory.xContent(bytesReference) + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, bytesReference)) { return PARSER.apply(parser, null).build(); } catch (IOException e) { throw new ElasticsearchParseException("failed to parse modelSnapshot", e); diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/ChangePasswordRequestBuilder.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/ChangePasswordRequestBuilder.java index 88da49baf6c..10c6c95c69e 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/ChangePasswordRequestBuilder.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/ChangePasswordRequestBuilder.java @@ -12,6 +12,7 @@ import org.elasticsearch.client.ElasticsearchClient; import org.elasticsearch.common.ValidationException; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.settings.SecureString; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; @@ -65,7 +66,8 @@ public class ChangePasswordRequestBuilder */ public ChangePasswordRequestBuilder source(BytesReference source, XContentType xContentType) throws IOException { // EMPTY is ok here because we never call namedObject - try (XContentParser parser = xContentType.xContent().createParser(NamedXContentRegistry.EMPTY, source)) { + try (XContentParser parser = xContentType.xContent() + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, source)) { XContentUtils.verifyObject(parser); XContentParser.Token token; String currentFieldName = null; diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/PutUserRequestBuilder.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/PutUserRequestBuilder.java index 0967ab256e9..0ce7518a81f 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/PutUserRequestBuilder.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/PutUserRequestBuilder.java @@ -14,6 +14,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.ValidationException; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.settings.SecureString; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser.Token; @@ -98,7 +99,8 @@ public class PutUserRequestBuilder extends ActionRequestBuilder Request.parseRequest(parser)); } diff --git a/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/config/DataDescriptionTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/config/DataDescriptionTests.java index 16ccb1d293a..67d137d2bcb 100644 --- a/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/config/DataDescriptionTests.java +++ b/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/config/DataDescriptionTests.java @@ -9,6 +9,7 @@ import org.elasticsearch.ElasticsearchException; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.bytes.BytesArray; 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.XContentParser; import org.elasticsearch.common.xcontent.json.JsonXContent; @@ -199,7 +200,8 @@ public class DataDescriptionTests extends AbstractSerializingTestCase DataDescription.CONFIG_PARSER.apply(parser, null)); assertThat(ex.getMessage(), containsString("[data_description] failed to parse field [format]")); @@ -212,7 +214,8 @@ public class DataDescriptionTests extends AbstractSerializingTestCase DataDescription.CONFIG_PARSER.apply(parser, null)); assertThat(ex.getMessage(), containsString("[data_description] failed to parse field [field_delimiter]")); @@ -225,7 +228,8 @@ public class DataDescriptionTests extends AbstractSerializingTestCase DataDescription.CONFIG_PARSER.apply(parser, null)); assertThat(ex.getMessage(), containsString("[data_description] failed to parse field [quote_character]")); diff --git a/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetFiltersAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetFiltersAction.java index b61b2762dde..8da4c94f301 100644 --- a/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetFiltersAction.java +++ b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetFiltersAction.java @@ -19,6 +19,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.inject.Inject; 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; @@ -81,7 +82,8 @@ public class TransportGetFiltersAction extends HandledTransportAction(Collections.singletonList(filter), 1, MlFilter.RESULTS_FIELD); @@ -120,7 +122,7 @@ public class TransportGetFiltersAction extends HandledTransportAction { BytesReference source = hit.getSourceRef(); XContentParser parser; try { - parser = XContentFactory.xContent(source).createParser(NamedXContentRegistry.EMPTY, source); + parser = XContentFactory.xContent(source).createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, source); } catch (IOException e) { throw new ElasticsearchParseException("failed to parse bucket", e); } diff --git a/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/BatchedInfluencersIterator.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/BatchedInfluencersIterator.java index 9a1a45212a4..5499b430f68 100644 --- a/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/BatchedInfluencersIterator.java +++ b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/BatchedInfluencersIterator.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.ml.job.persistence; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.client.Client; import org.elasticsearch.common.bytes.BytesReference; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; @@ -27,7 +28,7 @@ class BatchedInfluencersIterator extends BatchedResultsIterator { BytesReference source = hit.getSourceRef(); XContentParser parser; try { - parser = XContentFactory.xContent(source).createParser(NamedXContentRegistry.EMPTY, source); + parser = XContentFactory.xContent(source).createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, source); } catch (IOException e) { throw new ElasticsearchParseException("failed to parser influencer", e); } diff --git a/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/BatchedRecordsIterator.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/BatchedRecordsIterator.java index 50c1f523e65..23969bfdfe0 100644 --- a/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/BatchedRecordsIterator.java +++ b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/BatchedRecordsIterator.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.ml.job.persistence; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.client.Client; import org.elasticsearch.common.bytes.BytesReference; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; @@ -28,7 +29,7 @@ class BatchedRecordsIterator extends BatchedResultsIterator { BytesReference source = hit.getSourceRef(); XContentParser parser; try { - parser = XContentFactory.xContent(source).createParser(NamedXContentRegistry.EMPTY, source); + parser = XContentFactory.xContent(source).createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, source); } catch (IOException e) { throw new ElasticsearchParseException("failed to parse record", e); } diff --git a/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobProvider.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobProvider.java index 13eb54d7fc8..9a7e87aa3cd 100644 --- a/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobProvider.java +++ b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobProvider.java @@ -45,6 +45,7 @@ import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -473,7 +474,8 @@ public class JobProvider { private T parseSearchHit(SearchHit hit, BiFunction objectParser, Consumer errorHandler) { BytesReference source = hit.getSourceRef(); - try (XContentParser parser = XContentFactory.xContent(source).createParser(NamedXContentRegistry.EMPTY, source)) { + try (XContentParser parser = XContentFactory.xContent(source) + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, source)) { return objectParser.apply(parser, null); } catch (IOException e) { errorHandler.accept(new ElasticsearchParseException("failed to parse " + hit.getType(), e)); @@ -485,7 +487,8 @@ public class JobProvider { Consumer errorHandler) { BytesReference source = getResponse.getSourceAsBytesRef(); - try (XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser(NamedXContentRegistry.EMPTY, source)) { + try (XContentParser parser = XContentFactory.xContent(XContentType.JSON) + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, source)) { return objectParser.apply(parser, null); } catch (IOException e) { errorHandler.accept(new ElasticsearchParseException("failed to parse " + getResponse.getType(), e)); @@ -520,7 +523,8 @@ public class JobProvider { List results = new ArrayList<>(); for (SearchHit hit : hits.getHits()) { BytesReference source = hit.getSourceRef(); - try (XContentParser parser = XContentFactory.xContent(source).createParser(NamedXContentRegistry.EMPTY, source)) { + try (XContentParser parser = XContentFactory.xContent(source) + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, source)) { Bucket bucket = Bucket.PARSER.apply(parser, null); results.add(bucket); } catch (IOException e) { @@ -650,7 +654,8 @@ public class JobProvider { List results = new ArrayList<>(hits.length); for (SearchHit hit : hits) { BytesReference source = hit.getSourceRef(); - try (XContentParser parser = XContentFactory.xContent(source).createParser(NamedXContentRegistry.EMPTY, source)) { + try (XContentParser parser = XContentFactory.xContent(source) + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, source)) { CategoryDefinition categoryDefinition = CategoryDefinition.PARSER.apply(parser, null); results.add(categoryDefinition); } catch (IOException e) { @@ -683,7 +688,8 @@ public class JobProvider { List results = new ArrayList<>(); for (SearchHit hit : searchResponse.getHits().getHits()) { BytesReference source = hit.getSourceRef(); - try (XContentParser parser = XContentFactory.xContent(source).createParser(NamedXContentRegistry.EMPTY, source)) { + try (XContentParser parser = XContentFactory.xContent(source) + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, source)) { results.add(AnomalyRecord.PARSER.apply(parser, null)); } catch (IOException e) { throw new ElasticsearchParseException("failed to parse records", e); @@ -730,7 +736,8 @@ public class JobProvider { List influencers = new ArrayList<>(); for (SearchHit hit : response.getHits().getHits()) { BytesReference source = hit.getSourceRef(); - try (XContentParser parser = XContentFactory.xContent(source).createParser(NamedXContentRegistry.EMPTY, source)) { + try (XContentParser parser = XContentFactory.xContent(source) + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, source)) { influencers.add(Influencer.PARSER.apply(parser, null)); } catch (IOException e) { throw new ElasticsearchParseException("failed to parse influencer", e); @@ -873,7 +880,8 @@ public class JobProvider { for (SearchHit hit : searchResponse.getHits().getHits()) { BytesReference source = hit.getSourceRef(); - try (XContentParser parser = XContentFactory.xContent(source).createParser(NamedXContentRegistry.EMPTY, source)) { + try (XContentParser parser = XContentFactory.xContent(source) + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, source)) { ModelPlot modelPlot = ModelPlot.PARSER.apply(parser, null); results.add(modelPlot); } catch (IOException e) { @@ -1207,7 +1215,8 @@ public class JobProvider { BytesReference docSource = getDocResponse.getSourceAsBytesRef(); try (XContentParser parser = - XContentFactory.xContent(docSource).createParser(NamedXContentRegistry.EMPTY, docSource)) { + XContentFactory.xContent(docSource) + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, docSource)) { Calendar calendar = Calendar.PARSER.apply(parser, null).build(); listener.onResponse(calendar); } diff --git a/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/logging/CppLogMessageHandler.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/logging/CppLogMessageHandler.java index c57096e0e60..5c684582540 100644 --- a/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/logging/CppLogMessageHandler.java +++ b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/logging/CppLogMessageHandler.java @@ -15,6 +15,7 @@ import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.bytes.CompositeBytesReference; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.util.concurrent.ConcurrentCollections; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContent; import org.elasticsearch.common.xcontent.XContentFactory; @@ -220,7 +221,8 @@ public class CppLogMessageHandler implements Closeable { private void parseMessage(XContent xContent, BytesReference bytesRef) { try { - XContentParser parser = xContent.createParser(NamedXContentRegistry.EMPTY, bytesRef); + XContentParser parser = xContent + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, bytesRef); CppLogMessage msg = CppLogMessage.PARSER.apply(parser, null); Level level = Level.getLevel(msg.getLevel()); if (level == null) { diff --git a/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/normalizer/output/NormalizerResultHandler.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/normalizer/output/NormalizerResultHandler.java index c5d91d372e8..c213f4854d5 100644 --- a/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/normalizer/output/NormalizerResultHandler.java +++ b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/normalizer/output/NormalizerResultHandler.java @@ -10,6 +10,7 @@ import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.bytes.CompositeBytesReference; 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.XContent; import org.elasticsearch.common.xcontent.XContentFactory; @@ -79,7 +80,8 @@ public class NormalizerResultHandler extends AbstractComponent { } private void parseResult(XContent xContent, BytesReference bytesRef) throws IOException { - XContentParser parser = xContent.createParser(NamedXContentRegistry.EMPTY, bytesRef); + XContentParser parser = xContent + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, bytesRef); NormalizerResult result = NormalizerResult.PARSER.apply(parser, null); normalizedResults.add(result); } diff --git a/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/retention/ExpiredForecastsRemover.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/retention/ExpiredForecastsRemover.java index 2052a2023bb..4c8b9a714a2 100644 --- a/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/retention/ExpiredForecastsRemover.java +++ b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/retention/ExpiredForecastsRemover.java @@ -13,6 +13,7 @@ import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.client.Client; 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; @@ -117,7 +118,7 @@ public class ExpiredForecastsRemover implements MlDataRemover { for (SearchHit hit : hits.getHits()) { XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser( - NamedXContentRegistry.EMPTY, hit.getSourceRef()); + NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, hit.getSourceRef()); ForecastRequestStats forecastRequestStats = ForecastRequestStats.PARSER.apply(parser, null); if (forecastRequestStats.getExpiryTime().toEpochMilli() < cutoffEpochMs) { forecastsToDelete.add(forecastRequestStats); diff --git a/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/notifications/AuditorTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/notifications/AuditorTests.java index dc5e679bf09..7afb98559f3 100644 --- a/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/notifications/AuditorTests.java +++ b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/notifications/AuditorTests.java @@ -13,6 +13,7 @@ import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.ThreadContext; +import org.elasticsearch.common.xcontent.DeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; @@ -95,7 +96,8 @@ public class AuditorTests extends ESTestCase { } private AuditMessage parseAuditMessage(BytesReference msg) throws IOException { - XContentParser parser = XContentFactory.xContent(msg).createParser(NamedXContentRegistry.EMPTY, msg); + XContentParser parser = XContentFactory.xContent(msg) + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, msg); return AuditMessage.PARSER.apply(parser, null); } } diff --git a/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/FilteredMonitoringDoc.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/FilteredMonitoringDoc.java index fc70e9422b9..77297148012 100644 --- a/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/FilteredMonitoringDoc.java +++ b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/FilteredMonitoringDoc.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.monitoring.exporter; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.util.set.Sets; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.XContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -59,7 +60,7 @@ public abstract class FilteredMonitoringDoc extends MonitoringDoc { try (XContentBuilder filteredBuilder = new XContentBuilder(xContent, out, filters)) { super.toXContent(filteredBuilder, params); } - try (XContentParser parser = xContent.createParser(EMPTY, out.bytes())) { + try (XContentParser parser = xContent.createParser(EMPTY, LoggingDeprecationHandler.INSTANCE, out.bytes())) { return builder.copyCurrentStructure(parser); } } diff --git a/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/BaseMonitoringDocTestCase.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/BaseMonitoringDocTestCase.java index 5785f2e529d..608b27578bc 100644 --- a/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/BaseMonitoringDocTestCase.java +++ b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/BaseMonitoringDocTestCase.java @@ -12,6 +12,7 @@ import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.transport.TransportAddress; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -139,7 +140,8 @@ public abstract class BaseMonitoringDocTestCase extends final T document = createMonitoringDoc(cluster, timestamp, interval, node, system, type, id); final BytesReference bytes = XContentHelper.toXContent(document, xContentType, false); - try (XContentParser parser = xContentType.xContent().createParser(NamedXContentRegistry.EMPTY, bytes)) { + try (XContentParser parser = xContentType.xContent() + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, bytes)) { final Map map = parser.map(); assertThat(map.get("cluster_uuid"), equalTo(cluster)); diff --git a/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/NativeRoleMappingStore.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/NativeRoleMappingStore.java index 771119af6f9..3faa8bf508e 100644 --- a/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/NativeRoleMappingStore.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/NativeRoleMappingStore.java @@ -19,6 +19,7 @@ import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.ThreadContext; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -157,7 +158,8 @@ public class NativeRoleMappingStore extends AbstractComponent implements UserRol } private static XContentParser getParser(BytesReference source) throws IOException { - return XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, source); + return XContentType.JSON.xContent() + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, source); } /** diff --git a/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/saml/TransportSamlInvalidateSessionActionTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/saml/TransportSamlInvalidateSessionActionTests.java index e8f7eaf877b..c9511fb8c48 100644 --- a/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/saml/TransportSamlInvalidateSessionActionTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/saml/TransportSamlInvalidateSessionActionTests.java @@ -34,6 +34,7 @@ import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.io.PathUtils; 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.XContentType; import org.elasticsearch.env.Environment; @@ -201,7 +202,8 @@ public class TransportSamlInvalidateSessionActionTests extends SamlTestCase { private SearchHit tokenHit(int idx, BytesReference source) { try { - final Map sourceMap = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, source).map(); + final Map sourceMap = XContentType.JSON.xContent() + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, source).map(); final Map accessToken = (Map) sourceMap.get("access_token"); final Map userToken = (Map) accessToken.get("user_token"); final SearchHit hit = new SearchHit(idx, "token_" + userToken.get("id"), null, null); diff --git a/plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/RestRequestFilterTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/RestRequestFilterTests.java index 62cfa903922..37d6829e012 100644 --- a/plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/RestRequestFilterTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/RestRequestFilterTests.java @@ -7,6 +7,7 @@ package org.elasticsearch.xpack.security.rest; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; +import org.elasticsearch.common.xcontent.DeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.rest.RestRequest; @@ -30,7 +31,8 @@ public class RestRequestFilterTests extends ESTestCase { RestRequest filtered = filter.getFilteredRequest(restRequest); assertNotEquals(content, filtered.content()); - Map map = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, filtered.content()).map(); + Map map = XContentType.JSON.xContent() + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, filtered.content()).map(); Map root = (Map) map.get("root"); assertNotNull(root); Map second = (Map) root.get("second"); @@ -47,7 +49,8 @@ public class RestRequestFilterTests extends ESTestCase { RestRequest filtered = filter.getFilteredRequest(restRequest); assertNotEquals(content, filtered.content()); - Map map = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, filtered.content()).map(); + Map map = XContentType.JSON.xContent() + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, filtered.content()).map(); Map root = (Map) map.get("root"); assertNotNull(root); Map second = (Map) root.get("second"); @@ -64,7 +67,8 @@ public class RestRequestFilterTests extends ESTestCase { RestRequest filtered = filter.getFilteredRequest(restRequest); assertNotEquals(content, filtered.content()); - Map map = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, filtered.content()).map(); + Map map = XContentType.JSON.xContent() + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, filtered.content()).map(); Map root = (Map) map.get("root"); assertNotNull(root); Map second = (Map) root.get("second"); diff --git a/plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/SecurityRestFilterTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/SecurityRestFilterTests.java index 87e81e16a86..a1ec7b1eb0c 100644 --- a/plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/SecurityRestFilterTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/SecurityRestFilterTests.java @@ -11,6 +11,7 @@ import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.bytes.BytesArray; 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.XContentType; import org.elasticsearch.common.xcontent.json.JsonXContent; @@ -143,8 +144,9 @@ public class SecurityRestFilterTests extends ESTestCase { assertEquals(restRequest, handlerRequest.get()); assertEquals(restRequest.content(), handlerRequest.get().content()); - Map original = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, handlerRequest.get() - .content()).map(); + Map original = XContentType.JSON.xContent() + .createParser(NamedXContentRegistry.EMPTY, + DeprecationHandler.THROW_UNSUPPORTED_OPERATION, handlerRequest.get().content()).map(); assertEquals(2, original.size()); assertEquals(SecuritySettingsSourceField.TEST_PASSWORD, original.get("password")); assertEquals("bar", original.get("foo")); @@ -152,8 +154,9 @@ public class SecurityRestFilterTests extends ESTestCase { assertNotEquals(restRequest, authcServiceRequest.get()); assertNotEquals(restRequest.content(), authcServiceRequest.get().content()); - Map map = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, authcServiceRequest.get() - .content()).map(); + Map map = XContentType.JSON.xContent() + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, + authcServiceRequest.get().content()).map(); assertEquals(1, map.size()); assertEquals("bar", map.get("foo")); } diff --git a/plugin/sql/sql-shared-client/src/main/java/org/elasticsearch/xpack/sql/client/HttpClient.java b/plugin/sql/sql-shared-client/src/main/java/org/elasticsearch/xpack/sql/client/HttpClient.java index 1b885d5b1f9..e3919bd1ede 100644 --- a/plugin/sql/sql-shared-client/src/main/java/org/elasticsearch/xpack/sql/client/HttpClient.java +++ b/plugin/sql/sql-shared-client/src/main/java/org/elasticsearch/xpack/sql/client/HttpClient.java @@ -11,6 +11,7 @@ import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.io.Streams; import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentHelper; @@ -156,7 +157,7 @@ public class HttpClient { private Response fromXContent(XContentType xContentType, BytesReference bytesReference, CheckedFunction responseParser) { - try (XContentParser parser = xContentType.xContent().createParser(registry, bytesReference)) { + try (XContentParser parser = xContentType.xContent().createParser(registry, LoggingDeprecationHandler.INSTANCE, bytesReference)) { return responseParser.apply(parser); } catch (IOException ex) { throw new ClientException("Cannot parse response", ex); diff --git a/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/http/ExecutableHttpInput.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/http/ExecutableHttpInput.java index c4dad3b27c6..482b450c2f0 100644 --- a/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/http/ExecutableHttpInput.java +++ b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/http/ExecutableHttpInput.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.watcher.input.http; import org.apache.logging.log4j.Logger; import org.elasticsearch.ElasticsearchParseException; +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,8 @@ public class ExecutableHttpInput extends ExecutableInput errors = new ArrayList<>(); // EMPTY is safe here because we never call namedObject - try (XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, response.body())) { + try (XContentParser parser = JsonXContent.jsonXContent + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, response.body())) { XContentParser.Token token = parser.currentToken(); if (token == null) { token = parser.nextToken(); diff --git a/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/SentEvent.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/SentEvent.java index 93afcb54ae2..fa6c07a67bd 100644 --- a/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/SentEvent.java +++ b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/SentEvent.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.watcher.notification.pagerduty; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.ParseField; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -103,7 +104,8 @@ public class SentEvent implements ToXContentObject { // based on https://developer.pagerduty.com/documentation/rest/errors try { // EMPTY is safe here because we never call namedObject - XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, response.body()); + XContentParser parser = JsonXContent.jsonXContent + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, response.body()); parser.nextToken(); String message = null; diff --git a/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateService.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateService.java index 598105a48eb..5ee7da9025a 100644 --- a/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateService.java +++ b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateService.java @@ -9,6 +9,7 @@ import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.common.bytes.BytesReference; 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; @@ -63,7 +64,8 @@ public class WatcherSearchTemplateService extends AbstractComponent { SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); BytesReference source = request.getSearchSource(); if (source != null && source.length() > 0) { - try (XContentParser parser = XContentFactory.xContent(source).createParser(xContentRegistry, source)) { + try (XContentParser parser = XContentFactory.xContent(source) + .createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, source)) { sourceBuilder.parseXContent(parser); searchRequest.source(sourceBuilder); } diff --git a/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/watch/WatchParser.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/watch/WatchParser.java index 26d0534af3f..f4d05e2c8f3 100644 --- a/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/watch/WatchParser.java +++ b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/watch/WatchParser.java @@ -11,6 +11,7 @@ import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; @@ -101,8 +102,9 @@ public class WatchParser extends AbstractComponent { logger.trace("parsing watch [{}] ", source.utf8ToString()); } // EMPTY is safe here because we never use namedObject - try (WatcherXContentParser parser = new WatcherXContentParser(xContentType.xContent().createParser(NamedXContentRegistry.EMPTY, - source), now, withSecrets ? cryptoService : null)) { + try (WatcherXContentParser parser = new WatcherXContentParser(xContentType.xContent() + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, source), + now, withSecrets ? cryptoService : null)) { parser.nextToken(); return parse(id, includeStatus, parser); } catch (IOException ioe) { diff --git a/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpProxyTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpProxyTests.java index ce54e464095..30f2f9b4fd5 100644 --- a/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpProxyTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpProxyTests.java @@ -6,6 +6,7 @@ package org.elasticsearch.xpack.watcher.common.http; import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.common.xcontent.DeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -32,7 +33,7 @@ public class HttpProxyTests extends ESTestCase { } builder.endObject(); try (XContentParser parser = XContentFactory.xContent(XContentType.JSON) - .createParser(NamedXContentRegistry.EMPTY, builder.bytes())) { + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, builder.bytes())) { parser.nextToken(); HttpProxy proxy = HttpProxy.parse(parser); assertThat(proxy.getHost(), is(host)); @@ -50,7 +51,7 @@ public class HttpProxyTests extends ESTestCase { .field("host", "localhost").field("port", 12345).field("scheme", "invalid") .endObject(); try (XContentParser parser = XContentFactory.xContent(XContentType.JSON) - .createParser(NamedXContentRegistry.EMPTY, builder.bytes())) { + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, builder.bytes())) { parser.nextToken(); expectThrows(IllegalArgumentException.class, () -> HttpProxy.parse(parser)); } @@ -61,7 +62,7 @@ public class HttpProxyTests extends ESTestCase { .field("host", "localhost").field("port", -1) .endObject(); try (XContentParser parser = XContentFactory.xContent(XContentType.JSON) - .createParser(NamedXContentRegistry.EMPTY, builder.bytes())) { + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, builder.bytes())) { parser.nextToken(); expectThrows(ElasticsearchParseException.class, () -> HttpProxy.parse(parser)); } @@ -72,7 +73,7 @@ public class HttpProxyTests extends ESTestCase { .field("port", -1) .endObject(); try (XContentParser parser = XContentFactory.xContent(XContentType.JSON) - .createParser(NamedXContentRegistry.EMPTY, builder.bytes())) { + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, builder.bytes())) { parser.nextToken(); expectThrows(ElasticsearchParseException.class, () -> HttpProxy.parse(parser)); } @@ -83,7 +84,7 @@ public class HttpProxyTests extends ESTestCase { .field("host", "localhost") .endObject(); try (XContentParser parser = XContentFactory.xContent(XContentType.JSON) - .createParser(NamedXContentRegistry.EMPTY, builder.bytes())) { + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, builder.bytes())) { parser.nextToken(); expectThrows(ElasticsearchParseException.class, () -> HttpProxy.parse(parser)); } diff --git a/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java index 6b739030996..adba6f880d5 100644 --- a/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java @@ -21,6 +21,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; import org.elasticsearch.common.util.concurrent.ThreadContext; +import org.elasticsearch.common.xcontent.DeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; @@ -1018,8 +1019,8 @@ public class ExecutionServiceTests extends ESTestCase { final AtomicBoolean assertionsTriggered = new AtomicBoolean(false); doAnswer(invocation -> { UpdateRequest request = (UpdateRequest) invocation.getArguments()[0]; - try (XContentParser parser = - XContentFactory.xContent(XContentType.JSON).createParser(NamedXContentRegistry.EMPTY, request.doc().source())) { + try (XContentParser parser = XContentFactory.xContent(XContentType.JSON) + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, request.doc().source())) { Map map = parser.map(); Map state = ObjectPath.eval("status.state", map); assertThat(state, is(nullValue())); diff --git a/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputTests.java index 694d8bee815..d3b62b1a499 100644 --- a/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputTests.java @@ -9,6 +9,7 @@ import io.netty.handler.codec.http.HttpHeaders; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.collect.MapBuilder; 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; @@ -334,7 +335,8 @@ public class HttpInputTests extends ESTestCase { try (XContentBuilder builder = jsonBuilder()) { result.toXContent(builder, ToXContent.EMPTY_PARAMS); BytesReference bytes = builder.bytes(); - try (XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser(NamedXContentRegistry.EMPTY, bytes)) { + try (XContentParser parser = XContentFactory.xContent(XContentType.JSON) + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, bytes)) { Map data = parser.map(); String reason = ObjectPath.eval("error.reason", data); assertThat(reason, is("could not connect")); diff --git a/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchInputTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchInputTests.java index 3cd908228cd..94253c84cef 100644 --- a/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchInputTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchInputTests.java @@ -15,6 +15,7 @@ import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.ThreadContext; +import org.elasticsearch.common.xcontent.DeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -164,8 +165,8 @@ public class SearchInputTests extends ESTestCase { try (XContentBuilder builder = jsonBuilder().startObject().startObject("request") .startArray("indices").value("foo").endArray().endObject().endObject(); - XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser(NamedXContentRegistry.EMPTY, - builder.bytes())) { + XContentParser parser = XContentFactory.xContent(XContentType.JSON) + .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, builder.bytes())) { parser.nextToken(); // advance past the first starting object diff --git a/qa/ml-native-tests/src/test/java/org/elasticsearch/xpack/ml/integration/MlNativeAutodetectIntegTestCase.java b/qa/ml-native-tests/src/test/java/org/elasticsearch/xpack/ml/integration/MlNativeAutodetectIntegTestCase.java index 9b958e3ca58..5452c78e1c3 100644 --- a/qa/ml-native-tests/src/test/java/org/elasticsearch/xpack/ml/integration/MlNativeAutodetectIntegTestCase.java +++ b/qa/ml-native-tests/src/test/java/org/elasticsearch/xpack/ml/integration/MlNativeAutodetectIntegTestCase.java @@ -17,6 +17,7 @@ import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.common.xcontent.DeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; @@ -354,7 +355,7 @@ abstract class MlNativeAutodetectIntegTestCase extends ESIntegTestCase { assertThat(hits.getTotalHits(), equalTo(1L)); try { XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser( - NamedXContentRegistry.EMPTY, hits.getHits()[0].getSourceRef()); + NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, hits.getHits()[0].getSourceRef()); return ForecastRequestStats.PARSER.apply(parser, null); } catch (IOException e) { throw new IllegalStateException(e); @@ -373,7 +374,7 @@ abstract class MlNativeAutodetectIntegTestCase extends ESIntegTestCase { for (SearchHit hit : hits) { try { XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser( - NamedXContentRegistry.EMPTY, hit.getSourceRef()); + NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, hit.getSourceRef()); forecastStats.add(ForecastRequestStats.PARSER.apply(parser, null)); } catch (IOException e) { throw new IllegalStateException(e); @@ -407,7 +408,7 @@ abstract class MlNativeAutodetectIntegTestCase extends ESIntegTestCase { for (SearchHit hit : hits) { try { XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser( - NamedXContentRegistry.EMPTY, hit.getSourceRef()); + NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, hit.getSourceRef()); forecasts.add(Forecast.PARSER.apply(parser, null)); } catch (IOException e) { throw new IllegalStateException(e);