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@e0b52bf050
This commit is contained in:
parent
e8ef20b219
commit
affc9e3563
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<PutUserRequest,
|
|||
Objects.requireNonNull(xContentType);
|
||||
username(username);
|
||||
// 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;
|
||||
|
|
|
@ -12,6 +12,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.ToXContentObject;
|
||||
|
@ -143,7 +144,8 @@ public class ExpressionRoleMapping implements ToXContentObject, Writeable {
|
|||
*/
|
||||
public static ExpressionRoleMapping parse(String name, BytesReference source, XContentType xContentType) throws IOException {
|
||||
final NamedXContentRegistry registry = NamedXContentRegistry.EMPTY;
|
||||
try (XContentParser parser = xContentType.xContent().createParser(registry, source)) {
|
||||
try (XContentParser parser = xContentType.xContent()
|
||||
.createParser(registry, LoggingDeprecationHandler.INSTANCE, source)) {
|
||||
return parse(name, parser);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,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.Streamable;
|
||||
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
@ -218,7 +219,8 @@ public class RoleDescriptor implements ToXContentObject {
|
|||
throws IOException {
|
||||
assert name != null;
|
||||
// EMPTY is safe here because we never use namedObject
|
||||
try (XContentParser parser = xContentType.xContent().createParser(NamedXContentRegistry.EMPTY, source)) {
|
||||
try (XContentParser parser = xContentType.xContent()
|
||||
.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, source)) {
|
||||
return parse(name, parser, allow2xFormat);
|
||||
}
|
||||
}
|
||||
|
@ -286,7 +288,8 @@ public class RoleDescriptor implements ToXContentObject {
|
|||
|
||||
public static RoleDescriptor parsePrivilegesCheck(String description, BytesReference source, XContentType xContentType)
|
||||
throws IOException {
|
||||
try (XContentParser parser = xContentType.xContent().createParser(NamedXContentRegistry.EMPTY, source)) {
|
||||
try (XContentParser parser = xContentType.xContent()
|
||||
.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, source)) {
|
||||
// advance to the START_OBJECT token
|
||||
XContentParser.Token token = parser.nextToken();
|
||||
if (token != XContentParser.Token.START_OBJECT) {
|
||||
|
|
|
@ -10,6 +10,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.XContentBuilder;
|
||||
|
@ -105,7 +106,7 @@ public class XContentSource implements ToXContent {
|
|||
}
|
||||
|
||||
public XContentParser parser(NamedXContentRegistry xContentRegistry) throws IOException {
|
||||
return contentType.xContent().createParser(xContentRegistry, bytes);
|
||||
return contentType.xContent().createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, bytes);
|
||||
}
|
||||
|
||||
public static XContentSource readFrom(StreamInput in) throws IOException {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.core.ml.action;
|
||||
|
||||
import org.elasticsearch.common.xcontent.DeprecationHandler;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
@ -41,7 +42,7 @@ public class ValidateJobConfigActionRequestTests extends AbstractStreamableTestC
|
|||
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
|
||||
XContentBuilder xContentBuilder = jobConfiguration.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
XContentParser parser = XContentFactory.xContent(XContentType.JSON)
|
||||
.createParser(NamedXContentRegistry.EMPTY, xContentBuilder.bytes());
|
||||
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, xContentBuilder.bytes());
|
||||
|
||||
expectThrows(IllegalArgumentException.class, () -> Request.parseRequest(parser));
|
||||
}
|
||||
|
|
|
@ -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<DataDescri
|
|||
|
||||
public void testInvalidDataFormat() throws Exception {
|
||||
BytesArray json = new BytesArray("{ \"format\":\"INEXISTENT_FORMAT\" }");
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, json);
|
||||
XContentParser parser = JsonXContent.jsonXContent
|
||||
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, json);
|
||||
ParsingException ex = expectThrows(ParsingException.class,
|
||||
() -> 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<DataDescri
|
|||
|
||||
public void testInvalidFieldDelimiter() throws Exception {
|
||||
BytesArray json = new BytesArray("{ \"field_delimiter\":\",,\" }");
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, json);
|
||||
XContentParser parser = JsonXContent.jsonXContent
|
||||
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, json);
|
||||
ParsingException ex = expectThrows(ParsingException.class,
|
||||
() -> 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<DataDescri
|
|||
|
||||
public void testInvalidQuoteCharacter() throws Exception {
|
||||
BytesArray json = new BytesArray("{ \"quote_character\":\"''\" }");
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, json);
|
||||
XContentParser parser = JsonXContent.jsonXContent
|
||||
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, json);
|
||||
ParsingException ex = expectThrows(ParsingException.class,
|
||||
() -> DataDescription.CONFIG_PARSER.apply(parser, null));
|
||||
assertThat(ex.getMessage(), containsString("[data_description] failed to parse field [quote_character]"));
|
||||
|
|
|
@ -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<GetFilters
|
|||
if (getDocResponse.isExists()) {
|
||||
BytesReference docSource = getDocResponse.getSourceAsBytesRef();
|
||||
XContentParser parser =
|
||||
XContentFactory.xContent(docSource).createParser(NamedXContentRegistry.EMPTY, docSource);
|
||||
XContentFactory.xContent(docSource)
|
||||
.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, docSource);
|
||||
MlFilter filter = MlFilter.PARSER.apply(parser, null).build();
|
||||
responseBody = new QueryPage<>(Collections.singletonList(filter), 1, MlFilter.RESULTS_FIELD);
|
||||
|
||||
|
@ -120,7 +122,7 @@ public class TransportGetFiltersAction extends HandledTransportAction<GetFilters
|
|||
for (SearchHit hit : response.getHits().getHits()) {
|
||||
BytesReference docSource = hit.getSourceRef();
|
||||
try (XContentParser parser = XContentFactory.xContent(docSource).createParser(
|
||||
NamedXContentRegistry.EMPTY, docSource)) {
|
||||
NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, docSource)) {
|
||||
docs.add(MlFilter.PARSER.apply(parser, null).build());
|
||||
} catch (IOException e) {
|
||||
this.onFailure(e);
|
||||
|
|
|
@ -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 BatchedBucketsIterator extends BatchedResultsIterator<Bucket> {
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -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<Influencer> {
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -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<AnomalyRecord> {
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -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, U> T parseSearchHit(SearchHit hit, BiFunction<XContentParser, U, T> objectParser,
|
||||
Consumer<Exception> 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<Exception> 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<Bucket> 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<CategoryDefinition> 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<AnomalyRecord> 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<Influencer> 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);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<T extends MonitoringDoc> 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<String, ?> map = parser.map();
|
||||
|
||||
assertThat(map.get("cluster_uuid"), equalTo(cluster));
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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<String, Object> sourceMap = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, source).map();
|
||||
final Map<String, Object> sourceMap = XContentType.JSON.xContent()
|
||||
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, source).map();
|
||||
final Map<String, Object> accessToken = (Map<String, Object>) sourceMap.get("access_token");
|
||||
final Map<String, Object> userToken = (Map<String, Object>) accessToken.get("user_token");
|
||||
final SearchHit hit = new SearchHit(idx, "token_" + userToken.get("id"), null, null);
|
||||
|
|
|
@ -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<String, Object> map = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, filtered.content()).map();
|
||||
Map<String, Object> map = XContentType.JSON.xContent()
|
||||
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, filtered.content()).map();
|
||||
Map<String, Object> root = (Map<String, Object>) map.get("root");
|
||||
assertNotNull(root);
|
||||
Map<String, Object> second = (Map<String, Object>) root.get("second");
|
||||
|
@ -47,7 +49,8 @@ public class RestRequestFilterTests extends ESTestCase {
|
|||
RestRequest filtered = filter.getFilteredRequest(restRequest);
|
||||
assertNotEquals(content, filtered.content());
|
||||
|
||||
Map<String, Object> map = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, filtered.content()).map();
|
||||
Map<String, Object> map = XContentType.JSON.xContent()
|
||||
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, filtered.content()).map();
|
||||
Map<String, Object> root = (Map<String, Object>) map.get("root");
|
||||
assertNotNull(root);
|
||||
Map<String, Object> second = (Map<String, Object>) root.get("second");
|
||||
|
@ -64,7 +67,8 @@ public class RestRequestFilterTests extends ESTestCase {
|
|||
RestRequest filtered = filter.getFilteredRequest(restRequest);
|
||||
assertNotEquals(content, filtered.content());
|
||||
|
||||
Map<String, Object> map = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, filtered.content()).map();
|
||||
Map<String, Object> map = XContentType.JSON.xContent()
|
||||
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, filtered.content()).map();
|
||||
Map<String, Object> root = (Map<String, Object>) map.get("root");
|
||||
assertNotNull(root);
|
||||
Map<String, Object> second = (Map<String, Object>) root.get("second");
|
||||
|
|
|
@ -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<String, Object> original = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, handlerRequest.get()
|
||||
.content()).map();
|
||||
Map<String, Object> 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<String, Object> map = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, authcServiceRequest.get()
|
||||
.content()).map();
|
||||
Map<String, Object> map = XContentType.JSON.xContent()
|
||||
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
|
||||
authcServiceRequest.get().content()).map();
|
||||
assertEquals(1, map.size());
|
||||
assertEquals("bar", map.get("foo"));
|
||||
}
|
||||
|
|
|
@ -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> Response fromXContent(XContentType xContentType, BytesReference bytesReference,
|
||||
CheckedFunction<XContentParser, Response, IOException> 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);
|
||||
|
|
|
@ -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<HttpInput, HttpInput.Re
|
|||
|
||||
if (contentType != null) {
|
||||
// EMPTY is safe here because we never use namedObject
|
||||
try (XContentParser parser = contentType.xContent().createParser(NamedXContentRegistry.EMPTY, response.body())) {
|
||||
try (XContentParser parser = contentType.xContent()
|
||||
.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, response.body())) {
|
||||
if (input.getExtractKeys() != null) {
|
||||
payloadMap.putAll(XContentFilterKeysUtils.filterMapOrdered(input.getExtractKeys(), parser));
|
||||
} else {
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.elasticsearch.common.logging.Loggers;
|
|||
import org.elasticsearch.common.settings.Setting;
|
||||
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.ObjectParser;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
@ -200,7 +201,8 @@ public class ReportingAttachmentParser implements EmailAttachmentParser<Reportin
|
|||
*/
|
||||
private String extractIdFromJson(String watchId, String attachmentId, BytesReference body) throws IOException {
|
||||
// EMPTY is safe here becaus we never call namedObject
|
||||
try (XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, body)) {
|
||||
try (XContentParser parser = JsonXContent.jsonXContent
|
||||
.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, body)) {
|
||||
KibanaReportingPayload payload = new KibanaReportingPayload();
|
||||
PAYLOAD_PARSER.parse(parser, payload, null);
|
||||
String path = payload.getPath();
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.elasticsearch.common.Strings;
|
|||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsException;
|
||||
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
@ -79,7 +80,8 @@ public class JiraAccount {
|
|||
settings.getAsSettings(ISSUE_DEFAULTS_SETTING).toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
builder.endObject();
|
||||
this.issueDefaults = Collections.unmodifiableMap(XContentType.JSON.xContent()
|
||||
.createParser(new NamedXContentRegistry(Collections.emptyList()), builder.bytes()).map());
|
||||
.createParser(new NamedXContentRegistry(Collections.emptyList()),
|
||||
LoggingDeprecationHandler.INSTANCE, builder.bytes()).map());
|
||||
} catch (IOException ex) {
|
||||
throw new UncheckedIOException(ex);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.apache.http.HttpStatus;
|
|||
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;
|
||||
|
@ -147,7 +148,8 @@ public class JiraIssue implements ToXContentObject {
|
|||
if (response.hasContent()) {
|
||||
final List<String> 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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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<String, Object> map = parser.map();
|
||||
Map<String, String> state = ObjectPath.eval("status.state", map);
|
||||
assertThat(state, is(nullValue()));
|
||||
|
|
|
@ -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<String, Object> data = parser.map();
|
||||
String reason = ObjectPath.eval("error.reason", data);
|
||||
assertThat(reason, is("could not connect"));
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue