mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-28 09:28:55 -04:00
Remove calls to deprecated xcontent method (#84733)
This removes many calls to the last remaining `createParser` method that I deprecated in #79814, migrating callers to one of the new methods that it created.
This commit is contained in:
parent
4607182ce8
commit
87ab933c8b
28 changed files with 75 additions and 173 deletions
|
@ -8,8 +8,6 @@ import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
|||
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
|
||||
import org.elasticsearch.search.fetch.subphase.FetchSourcePhase;
|
||||
import org.elasticsearch.search.lookup.SourceLookup;
|
||||
import org.elasticsearch.xcontent.DeprecationHandler;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
|
@ -108,8 +106,7 @@ public class FetchSourcePhaseBenchmark {
|
|||
XContentType.JSON.toParsedMediaType()
|
||||
);
|
||||
try (
|
||||
XContentParser parser = XContentType.JSON.xContent()
|
||||
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, sourceBytes.streamInput())
|
||||
XContentParser parser = XContentType.JSON.xContent().createParser(XContentParserConfiguration.EMPTY, sourceBytes.streamInput())
|
||||
) {
|
||||
builder.copyCurrentStructure(parser);
|
||||
return BytesReference.bytes(builder);
|
||||
|
|
|
@ -177,6 +177,7 @@ import org.elasticsearch.xcontent.DeprecationHandler;
|
|||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
@ -244,7 +245,7 @@ public class RestHighLevelClient implements Closeable {
|
|||
|
||||
// To be called using performClientRequest and performClientRequestAsync to ensure version compatibility check
|
||||
private final RestClient client;
|
||||
private final NamedXContentRegistry registry;
|
||||
private final XContentParserConfiguration parserConfig;
|
||||
private final CheckedConsumer<RestClient, IOException> doClose;
|
||||
private final boolean useAPICompatibility;
|
||||
|
||||
|
@ -297,11 +298,19 @@ public class RestHighLevelClient implements Closeable {
|
|||
) {
|
||||
this.client = Objects.requireNonNull(restClient, "restClient must not be null");
|
||||
this.doClose = Objects.requireNonNull(doClose, "doClose consumer must not be null");
|
||||
this.registry = new NamedXContentRegistry(
|
||||
NamedXContentRegistry registry = new NamedXContentRegistry(
|
||||
Stream.of(getDefaultNamedXContents().stream(), getProvidedNamedXContents().stream(), namedXContentEntries.stream())
|
||||
.flatMap(Function.identity())
|
||||
.collect(toList())
|
||||
);
|
||||
/*
|
||||
* Ignores deprecation warnings. This is appropriate because it is only
|
||||
* used to parse responses from Elasticsearch. Any deprecation warnings
|
||||
* emitted there just mean that you are talking to an old version of
|
||||
* Elasticsearch. There isn't anything you can do about the deprecation.
|
||||
*/
|
||||
this.parserConfig = XContentParserConfiguration.EMPTY.withRegistry(registry)
|
||||
.withDeprecationHandler(DeprecationHandler.IGNORE_DEPRECATIONS);
|
||||
if (useAPICompatibility == null && "true".equals(System.getenv(API_VERSIONING_ENV_VARIABLE))) {
|
||||
this.useAPICompatibility = true;
|
||||
} else {
|
||||
|
@ -1165,7 +1174,7 @@ public class RestHighLevelClient implements Closeable {
|
|||
if (xContentType == null) {
|
||||
throw new IllegalStateException("Unsupported Content-Type: " + entity.getContentType().getValue());
|
||||
}
|
||||
try (XContentParser parser = xContentType.xContent().createParser(registry, DEPRECATION_HANDLER, entity.getContent())) {
|
||||
try (XContentParser parser = xContentType.xContent().createParser(parserConfig, entity.getContent())) {
|
||||
return entityParser.apply(parser);
|
||||
}
|
||||
}
|
||||
|
@ -1506,14 +1515,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ignores deprecation warnings. This is appropriate because it is only
|
||||
* used to parse responses from Elasticsearch. Any deprecation warnings
|
||||
* emitted there just mean that you are talking to an old version of
|
||||
* Elasticsearch. There isn't anything you can do about the deprecation.
|
||||
*/
|
||||
private static final DeprecationHandler DEPRECATION_HANDLER = DeprecationHandler.IGNORE_DEPRECATIONS;
|
||||
|
||||
static List<NamedXContentRegistry.Entry> getDefaultNamedXContents() {
|
||||
Map<String, ContextParser<Object, ? extends Aggregation>> map = new HashMap<>();
|
||||
map.put(CardinalityAggregationBuilder.NAME, (p, c) -> ParsedCardinality.fromXContent(p, (String) c));
|
||||
|
|
|
@ -21,13 +21,12 @@ import com.fasterxml.jackson.core.util.JsonGeneratorDelegate;
|
|||
|
||||
import org.elasticsearch.core.CheckedConsumer;
|
||||
import org.elasticsearch.core.Streams;
|
||||
import org.elasticsearch.xcontent.DeprecationHandler;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.XContent;
|
||||
import org.elasticsearch.xcontent.XContentFactory;
|
||||
import org.elasticsearch.xcontent.XContentGenerationException;
|
||||
import org.elasticsearch.xcontent.XContentGenerator;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
import org.elasticsearch.xcontent.provider.filtering.FilterPathBasedFilter;
|
||||
|
||||
|
@ -444,14 +443,7 @@ public class JsonXContentGenerator implements XContentGenerator {
|
|||
@Override
|
||||
public void writeRawField(String name, InputStream content, XContentType contentType) throws IOException {
|
||||
if (mayWriteRawData(contentType) == false) {
|
||||
// EMPTY is safe here because we never call namedObject when writing raw data
|
||||
try (
|
||||
XContentParser parser = XContentFactory.xContent(contentType)
|
||||
// It's okay to pass the throwing deprecation handler
|
||||
// because we should not be writing raw fields when
|
||||
// generating JSON
|
||||
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, content)
|
||||
) {
|
||||
try (XContentParser parser = XContentFactory.xContent(contentType).createParser(XContentParserConfiguration.EMPTY, content)) {
|
||||
parser.nextToken();
|
||||
writeFieldName(name);
|
||||
copyCurrentStructure(parser);
|
||||
|
@ -493,13 +485,7 @@ public class JsonXContentGenerator implements XContentGenerator {
|
|||
}
|
||||
|
||||
protected void copyRawValue(InputStream stream, XContent xContent) throws IOException {
|
||||
// EMPTY is safe here because we never call namedObject
|
||||
try (
|
||||
XContentParser parser = xContent
|
||||
// It's okay to pass the throwing deprecation handler because we
|
||||
// should not be writing raw fields when generating JSON
|
||||
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, stream)
|
||||
) {
|
||||
try (XContentParser parser = xContent.createParser(XContentParserConfiguration.EMPTY, stream)) {
|
||||
copyCurrentStructure(parser);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,9 +14,8 @@ import org.elasticsearch.ingest.AbstractProcessor;
|
|||
import org.elasticsearch.ingest.ConfigurationUtils;
|
||||
import org.elasticsearch.ingest.IngestDocument;
|
||||
import org.elasticsearch.ingest.Processor;
|
||||
import org.elasticsearch.xcontent.DeprecationHandler;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.json.JsonXContent;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -77,11 +76,7 @@ public final class JsonProcessor extends AbstractProcessor {
|
|||
BytesReference bytesRef = fieldValue == null ? new BytesArray("null") : new BytesArray(fieldValue.toString());
|
||||
try (
|
||||
InputStream stream = bytesRef.streamInput();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(
|
||||
NamedXContentRegistry.EMPTY,
|
||||
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
|
||||
stream
|
||||
)
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(XContentParserConfiguration.EMPTY, stream)
|
||||
) {
|
||||
parser.allowDuplicateKeys(allowDuplicateKeys);
|
||||
XContentParser.Token token = parser.nextToken();
|
||||
|
|
|
@ -19,9 +19,9 @@ import org.elasticsearch.script.Script;
|
|||
import org.elasticsearch.script.ScriptException;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.script.ScriptType;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
import org.elasticsearch.xcontent.json.JsonXContent;
|
||||
|
||||
|
@ -110,7 +110,7 @@ public final class ScriptProcessor extends AbstractProcessor {
|
|||
XContentBuilder builder = XContentBuilder.builder(JsonXContent.jsonXContent).map(config);
|
||||
InputStream stream = BytesReference.bytes(builder).streamInput();
|
||||
XContentParser parser = XContentType.JSON.xContent()
|
||||
.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, stream)
|
||||
.createParser(XContentParserConfiguration.EMPTY.withDeprecationHandler(LoggingDeprecationHandler.INSTANCE), stream)
|
||||
) {
|
||||
Script script = Script.parse(parser);
|
||||
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
package org.elasticsearch.ingest.useragent;
|
||||
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.ingest.useragent.UserAgentParser.VersionedName;
|
||||
import org.elasticsearch.xcontent.XContentFactory;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -24,7 +24,6 @@ import java.util.Map;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.elasticsearch.ingest.useragent.UserAgentParser.VersionedName;
|
||||
import static org.elasticsearch.ingest.useragent.UserAgentParser.readParserConfigurations;
|
||||
|
||||
public class DeviceTypeParser {
|
||||
|
@ -40,9 +39,8 @@ public class DeviceTypeParser {
|
|||
private final HashMap<String, ArrayList<DeviceTypeSubPattern>> deviceTypePatterns = new HashMap<>();
|
||||
|
||||
public void init(InputStream regexStream) throws IOException {
|
||||
// EMPTY is safe here because we don't use namedObject
|
||||
XContentParser yamlParser = XContentFactory.xContent(XContentType.YAML)
|
||||
.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, regexStream);
|
||||
.createParser(XContentParserConfiguration.EMPTY, regexStream);
|
||||
|
||||
XContentParser.Token token = yamlParser.nextToken();
|
||||
|
||||
|
|
|
@ -9,10 +9,9 @@
|
|||
package org.elasticsearch.ingest.useragent;
|
||||
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.XContentFactory;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -50,7 +49,7 @@ final class UserAgentParser {
|
|||
private void init(InputStream regexStream) throws IOException {
|
||||
// EMPTY is safe here because we don't use namedObject
|
||||
XContentParser yamlParser = XContentFactory.xContent(XContentType.YAML)
|
||||
.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, regexStream);
|
||||
.createParser(XContentParserConfiguration.EMPTY, regexStream);
|
||||
|
||||
XContentParser.Token token = yamlParser.nextToken();
|
||||
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
|
||||
package org.elasticsearch.ingest.useragent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
|
||||
import org.elasticsearch.ingest.useragent.UserAgentParser.VersionedName;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.XContentFactory;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
|
@ -23,7 +23,6 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.ingest.useragent.UserAgentParser.VersionedName;
|
||||
import static org.elasticsearch.ingest.useragent.UserAgentParser.readParserConfigurations;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
|
@ -33,7 +32,7 @@ public class DeviceTypeParserTests extends ESTestCase {
|
|||
|
||||
private ArrayList<HashMap<String, String>> readTestDevices(InputStream regexStream, String keyName) throws IOException {
|
||||
XContentParser yamlParser = XContentFactory.xContent(XContentType.YAML)
|
||||
.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, regexStream);
|
||||
.createParser(XContentParserConfiguration.EMPTY, regexStream);
|
||||
|
||||
XContentParser.Token token = yamlParser.nextToken();
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.elasticsearch.painless.action.PainlessContextInfo;
|
|||
import org.elasticsearch.painless.action.PainlessContextInstanceBindingInfo;
|
||||
import org.elasticsearch.painless.action.PainlessContextMethodInfo;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.json.JsonXContent;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -36,7 +37,7 @@ public class ContextGeneratorCommon {
|
|||
public static List<PainlessContextInfo> getContextInfos() throws IOException {
|
||||
URLConnection getContextNames = new URL("http://" + System.getProperty("cluster.uri") + "/_scripts/painless/_context")
|
||||
.openConnection();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(null, null, getContextNames.getInputStream());
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(XContentParserConfiguration.EMPTY, getContextNames.getInputStream());
|
||||
parser.nextToken();
|
||||
parser.nextToken();
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -50,7 +51,7 @@ public class ContextGeneratorCommon {
|
|||
URLConnection getContextInfo = new URL(
|
||||
"http://" + System.getProperty("cluster.uri") + "/_scripts/painless/_context?context=" + contextName
|
||||
).openConnection();
|
||||
parser = JsonXContent.jsonXContent.createParser(null, null, getContextInfo.getInputStream());
|
||||
parser = JsonXContent.jsonXContent.createParser(XContentParserConfiguration.EMPTY, getContextInfo.getInputStream());
|
||||
contextInfos.add(PainlessContextInfo.fromXContent(parser));
|
||||
((HttpURLConnection) getContextInfo).disconnect();
|
||||
}
|
||||
|
|
|
@ -9,10 +9,8 @@ package org.elasticsearch.painless.action;
|
|||
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
|
||||
import org.elasticsearch.index.query.MatchAllQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.elasticsearch.painless.action.PainlessExecuteAction.Request.ContextSetup;
|
||||
|
@ -51,8 +49,7 @@ public class PainlessExecuteRequestTests extends AbstractWireSerializingTestCase
|
|||
|
||||
try (XContentBuilder builder = XContentBuilder.builder(xContent)) {
|
||||
builder.value(testInstance);
|
||||
StreamInput instanceInput = BytesReference.bytes(builder).streamInput();
|
||||
try (XContentParser parser = xContent.createParser(xContentRegistry(), LoggingDeprecationHandler.INSTANCE, instanceInput)) {
|
||||
try (XContentParser parser = createParser(xContent, BytesReference.bytes(builder).streamInput())) {
|
||||
PainlessExecuteAction.Request result = PainlessExecuteAction.Request.parse(parser);
|
||||
assertThat(result, equalTo(testInstance));
|
||||
}
|
||||
|
|
|
@ -54,10 +54,9 @@ import org.elasticsearch.script.ReindexScript;
|
|||
import org.elasticsearch.script.Script;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.xcontent.DeprecationHandler;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -323,8 +322,7 @@ public class Reindexer {
|
|||
// we need to convert
|
||||
try (
|
||||
InputStream stream = doc.getSource().streamInput();
|
||||
XContentParser parser = sourceXContentType.xContent()
|
||||
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, stream);
|
||||
XContentParser parser = sourceXContentType.xContent().createParser(XContentParserConfiguration.EMPTY, stream);
|
||||
XContentBuilder builder = XContentBuilder.builder(mainRequestXContentType.xContent())
|
||||
) {
|
||||
parser.nextToken();
|
||||
|
|
|
@ -33,9 +33,9 @@ import org.elasticsearch.index.reindex.RemoteInfo;
|
|||
import org.elasticsearch.index.reindex.ScrollableHitSource;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.XContentParseException;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -192,7 +192,10 @@ public class RemoteScrollableHitSource extends ScrollableHitSource {
|
|||
// EMPTY is safe here because we don't call namedObject
|
||||
try (
|
||||
XContentParser xContentParser = xContentType.xContent()
|
||||
.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, content)
|
||||
.createParser(
|
||||
XContentParserConfiguration.EMPTY.withDeprecationHandler(LoggingDeprecationHandler.INSTANCE),
|
||||
content
|
||||
)
|
||||
) {
|
||||
parsedResponse = parser.apply(xContentParser, xContentType);
|
||||
} catch (XContentParseException e) {
|
||||
|
|
|
@ -43,9 +43,9 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.test.hamcrest.ElasticsearchAssertions;
|
||||
import org.elasticsearch.test.rest.ESRestTestCase;
|
||||
import org.elasticsearch.test.rest.ObjectPath;
|
||||
import org.elasticsearch.xcontent.DeprecationHandler;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.test.rest.yaml.ObjectPath;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.json.JsonXContent;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -189,8 +189,7 @@ public class SearchStatesIT extends ESRestTestCase {
|
|||
Response response = localClient.performRequest(request);
|
||||
try (
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(
|
||||
NamedXContentRegistry.EMPTY,
|
||||
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
|
||||
XContentParserConfiguration.EMPTY,
|
||||
response.getEntity().getContent()
|
||||
)
|
||||
) {
|
||||
|
|
|
@ -19,7 +19,6 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.snapshots.SnapshotsService;
|
||||
import org.elasticsearch.test.rest.ESRestTestCase;
|
||||
import org.elasticsearch.test.rest.ObjectPath;
|
||||
import org.elasticsearch.xcontent.DeprecationHandler;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.json.JsonXContent;
|
||||
|
||||
|
@ -243,11 +242,7 @@ public class MultiVersionRepositoryAccessIT extends ESRestTestCase {
|
|||
private List<Map<String, Object>> listSnapshots(String repoName) throws IOException {
|
||||
try (
|
||||
InputStream entity = client().performRequest(new Request("GET", "/_snapshot/" + repoName + "/_all")).getEntity().getContent();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(
|
||||
xContentRegistry(),
|
||||
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
|
||||
entity
|
||||
)
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, entity)
|
||||
) {
|
||||
return (List<Map<String, Object>>) parser.map().get("snapshots");
|
||||
}
|
||||
|
|
|
@ -23,9 +23,8 @@ import org.elasticsearch.snapshots.AbstractSnapshotIntegTestCase;
|
|||
import org.elasticsearch.snapshots.SnapshotInfo;
|
||||
import org.elasticsearch.snapshots.SnapshotsService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.xcontent.DeprecationHandler;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.json.JsonXContent;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -444,11 +443,7 @@ public class RestGetSnapshotsIT extends AbstractSnapshotRestTestCase {
|
|||
private static GetSnapshotsResponse readSnapshotInfos(Response response) throws IOException {
|
||||
try (
|
||||
InputStream input = response.getEntity().getContent();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(
|
||||
NamedXContentRegistry.EMPTY,
|
||||
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
|
||||
input
|
||||
)
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(XContentParserConfiguration.EMPTY, input)
|
||||
) {
|
||||
return GetSnapshotsResponse.fromXContent(parser);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ import org.elasticsearch.common.io.stream.Writeable;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
|
||||
import org.elasticsearch.xcontent.AbstractObjectParser;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.ObjectParser;
|
||||
import org.elasticsearch.xcontent.ObjectParser.ValueType;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
|
@ -28,6 +27,7 @@ import org.elasticsearch.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.xcontent.XContentFactory;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParser.Token;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
import org.elasticsearch.xcontent.json.JsonXContent;
|
||||
|
||||
|
@ -303,8 +303,7 @@ public final class Script implements ToXContentObject, Writeable {
|
|||
try (
|
||||
InputStream stream = BytesReference.bytes(builder).streamInput();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(
|
||||
NamedXContentRegistry.EMPTY,
|
||||
LoggingDeprecationHandler.INSTANCE,
|
||||
XContentParserConfiguration.EMPTY.withDeprecationHandler(LoggingDeprecationHandler.INSTANCE),
|
||||
stream
|
||||
)
|
||||
) {
|
||||
|
|
|
@ -18,7 +18,6 @@ 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.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.ObjectParser;
|
||||
import org.elasticsearch.xcontent.ObjectParser.ValueType;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
|
@ -27,6 +26,7 @@ import org.elasticsearch.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.xcontent.XContentFactory;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParser.Token;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -188,7 +188,7 @@ public class StoredScriptSource implements SimpleDiffable<StoredScriptSource>, W
|
|||
try (
|
||||
InputStream stream = content.streamInput();
|
||||
XContentParser parser = xContentType.xContent()
|
||||
.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, stream)
|
||||
.createParser(XContentParserConfiguration.EMPTY.withDeprecationHandler(LoggingDeprecationHandler.INSTANCE), stream)
|
||||
) {
|
||||
Token token = parser.nextToken();
|
||||
|
||||
|
|
|
@ -12,12 +12,11 @@ import org.elasticsearch.common.bytes.BytesReference;
|
|||
import org.elasticsearch.common.util.set.Sets;
|
||||
import org.elasticsearch.core.CheckedFunction;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xcontent.DeprecationHandler;
|
||||
import org.elasticsearch.xcontent.FilterXContentParserWrapper;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.XContent;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
@ -52,10 +51,7 @@ public abstract class AbstractFilteringTestCase extends ESTestCase {
|
|||
return builder -> {
|
||||
try (InputStream stream = AbstractFilteringTestCase.class.getResourceAsStream(file)) {
|
||||
assertThat("Couldn't find [" + file + "]", stream, notNullValue());
|
||||
try (
|
||||
XContentParser parser = XContentType.JSON.xContent()
|
||||
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, stream)
|
||||
) {
|
||||
try (XContentParser parser = XContentType.JSON.xContent().createParser(XContentParserConfiguration.EMPTY, stream)) {
|
||||
// copyCurrentStructure does not property handle filters when it is passed a json parser. So we hide it.
|
||||
return builder.copyCurrentStructure(new FilterXContentParserWrapper(parser) {
|
||||
});
|
||||
|
|
|
@ -42,8 +42,8 @@ import org.elasticsearch.repositories.ShardGenerations;
|
|||
import org.elasticsearch.snapshots.SnapshotId;
|
||||
import org.elasticsearch.snapshots.SnapshotInfo;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
|
@ -114,7 +114,7 @@ public final class BlobStoreTestUtil {
|
|||
try (
|
||||
InputStream blob = blobContainer.readBlob(BlobStoreRepository.INDEX_FILE_PREFIX + latestGen);
|
||||
XContentParser parser = XContentType.JSON.xContent()
|
||||
.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, blob)
|
||||
.createParser(XContentParserConfiguration.EMPTY.withDeprecationHandler(LoggingDeprecationHandler.INSTANCE), blob)
|
||||
) {
|
||||
repositoryData = RepositoryData.snapshotsFromXContent(parser, latestGen, false);
|
||||
}
|
||||
|
|
|
@ -34,11 +34,10 @@ import org.elasticsearch.search.sort.SortOrder;
|
|||
import org.elasticsearch.search.suggest.SuggestBuilder;
|
||||
import org.elasticsearch.search.vectors.KnnSearchBuilder;
|
||||
import org.elasticsearch.test.AbstractQueryTestCase;
|
||||
import org.elasticsearch.xcontent.DeprecationHandler;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xcontent.XContentFactory;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -310,11 +309,7 @@ public class RandomSearchRequestGenerator {
|
|||
jsonBuilder.endArray();
|
||||
jsonBuilder.endObject();
|
||||
XContentParser parser = XContentFactory.xContent(XContentType.JSON)
|
||||
.createParser(
|
||||
NamedXContentRegistry.EMPTY,
|
||||
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
|
||||
BytesReference.bytes(jsonBuilder).streamInput()
|
||||
);
|
||||
.createParser(XContentParserConfiguration.EMPTY, BytesReference.bytes(jsonBuilder).streamInput());
|
||||
parser.nextToken();
|
||||
parser.nextToken();
|
||||
parser.nextToken();
|
||||
|
|
|
@ -11,11 +11,10 @@ import org.apache.http.util.EntityUtils;
|
|||
import org.elasticsearch.client.Response;
|
||||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.xcontent.DeprecationHandler;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.XContent;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -38,13 +37,7 @@ public class ObjectPath {
|
|||
}
|
||||
|
||||
public static ObjectPath createFromXContent(XContent xContent, BytesReference input) throws IOException {
|
||||
try (
|
||||
XContentParser parser = xContent.createParser(
|
||||
NamedXContentRegistry.EMPTY,
|
||||
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
|
||||
input.streamInput()
|
||||
)
|
||||
) {
|
||||
try (XContentParser parser = xContent.createParser(XContentParserConfiguration.EMPTY, input.streamInput())) {
|
||||
if (parser.nextToken() == XContentParser.Token.START_ARRAY) {
|
||||
return new ObjectPath(parser.listOrderedMap());
|
||||
}
|
||||
|
|
|
@ -7,10 +7,9 @@
|
|||
*/
|
||||
package org.elasticsearch.test.rest.yaml.restspec;
|
||||
|
||||
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
|
||||
import org.elasticsearch.test.ClasspathUtils;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.json.JsonXContent;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -94,13 +93,7 @@ public class ClientYamlSuiteRestSpec {
|
|||
|
||||
private static void parseSpecFile(ClientYamlSuiteRestApiParser restApiParser, Path jsonFile, ClientYamlSuiteRestSpec restSpec) {
|
||||
try (InputStream stream = Files.newInputStream(jsonFile)) {
|
||||
try (
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(
|
||||
NamedXContentRegistry.EMPTY,
|
||||
LoggingDeprecationHandler.INSTANCE,
|
||||
stream
|
||||
)
|
||||
) {
|
||||
try (XContentParser parser = JsonXContent.jsonXContent.createParser(XContentParserConfiguration.EMPTY, stream)) {
|
||||
String filename = jsonFile.getFileName().toString();
|
||||
if (filename.equals("_common.json")) {
|
||||
parseCommonSpec(parser, restSpec);
|
||||
|
|
|
@ -10,10 +10,10 @@ package org.elasticsearch.test.rest.yaml.section;
|
|||
import org.elasticsearch.client.NodeSelector;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.io.Channels;
|
||||
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.XContentParseException;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.yaml.YamlXContent;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -63,8 +63,7 @@ public class ClientYamlTestSuite {
|
|||
|
||||
try (
|
||||
XContentParser parser = YamlXContent.yamlXContent.createParser(
|
||||
executeableSectionRegistry,
|
||||
LoggingDeprecationHandler.INSTANCE,
|
||||
XContentParserConfiguration.EMPTY.withRegistry(executeableSectionRegistry),
|
||||
Files.newInputStream(file)
|
||||
)
|
||||
) {
|
||||
|
|
|
@ -10,12 +10,11 @@ import org.elasticsearch.ElasticsearchParseException;
|
|||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xcontent.DeprecationHandler;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.ToXContent;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xcontent.XContentFactory;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
|
||||
import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder;
|
||||
|
@ -37,11 +36,7 @@ public class HttpProxyTests extends ESTestCase {
|
|||
builder.endObject();
|
||||
try (
|
||||
XContentParser parser = XContentFactory.xContent(XContentType.JSON)
|
||||
.createParser(
|
||||
NamedXContentRegistry.EMPTY,
|
||||
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
|
||||
BytesReference.bytes(builder).streamInput()
|
||||
)
|
||||
.createParser(XContentParserConfiguration.EMPTY, BytesReference.bytes(builder).streamInput())
|
||||
) {
|
||||
parser.nextToken();
|
||||
HttpProxy proxy = HttpProxy.parse(parser);
|
||||
|
@ -63,11 +58,7 @@ public class HttpProxyTests extends ESTestCase {
|
|||
.endObject();
|
||||
try (
|
||||
XContentParser parser = XContentFactory.xContent(XContentType.JSON)
|
||||
.createParser(
|
||||
NamedXContentRegistry.EMPTY,
|
||||
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
|
||||
BytesReference.bytes(builder).streamInput()
|
||||
)
|
||||
.createParser(XContentParserConfiguration.EMPTY, BytesReference.bytes(builder).streamInput())
|
||||
) {
|
||||
parser.nextToken();
|
||||
expectThrows(IllegalArgumentException.class, () -> HttpProxy.parse(parser));
|
||||
|
@ -78,11 +69,7 @@ public class HttpProxyTests extends ESTestCase {
|
|||
XContentBuilder builder = jsonBuilder().startObject().field("host", "localhost").field("port", -1).endObject();
|
||||
try (
|
||||
XContentParser parser = XContentFactory.xContent(XContentType.JSON)
|
||||
.createParser(
|
||||
NamedXContentRegistry.EMPTY,
|
||||
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
|
||||
BytesReference.bytes(builder).streamInput()
|
||||
)
|
||||
.createParser(XContentParserConfiguration.EMPTY, BytesReference.bytes(builder).streamInput())
|
||||
) {
|
||||
parser.nextToken();
|
||||
expectThrows(ElasticsearchParseException.class, () -> HttpProxy.parse(parser));
|
||||
|
@ -93,11 +80,7 @@ public class HttpProxyTests extends ESTestCase {
|
|||
XContentBuilder builder = jsonBuilder().startObject().field("port", -1).endObject();
|
||||
try (
|
||||
XContentParser parser = XContentFactory.xContent(XContentType.JSON)
|
||||
.createParser(
|
||||
NamedXContentRegistry.EMPTY,
|
||||
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
|
||||
BytesReference.bytes(builder).streamInput()
|
||||
)
|
||||
.createParser(XContentParserConfiguration.EMPTY, BytesReference.bytes(builder).streamInput())
|
||||
) {
|
||||
parser.nextToken();
|
||||
expectThrows(ElasticsearchParseException.class, () -> HttpProxy.parse(parser));
|
||||
|
@ -108,11 +91,7 @@ public class HttpProxyTests extends ESTestCase {
|
|||
XContentBuilder builder = jsonBuilder().startObject().field("host", "localhost").endObject();
|
||||
try (
|
||||
XContentParser parser = XContentFactory.xContent(XContentType.JSON)
|
||||
.createParser(
|
||||
NamedXContentRegistry.EMPTY,
|
||||
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
|
||||
BytesReference.bytes(builder).streamInput()
|
||||
)
|
||||
.createParser(XContentParserConfiguration.EMPTY, BytesReference.bytes(builder).streamInput())
|
||||
) {
|
||||
parser.nextToken();
|
||||
expectThrows(ElasticsearchParseException.class, () -> HttpProxy.parse(parser));
|
||||
|
|
|
@ -34,11 +34,10 @@ import org.elasticsearch.index.get.GetResult;
|
|||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.xcontent.DeprecationHandler;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.ObjectPath;
|
||||
import org.elasticsearch.xcontent.XContentFactory;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
import org.elasticsearch.xpack.core.security.authc.Authentication;
|
||||
import org.elasticsearch.xpack.core.security.authc.AuthenticationField;
|
||||
|
@ -1136,11 +1135,7 @@ public class ExecutionServiceTests extends ESTestCase {
|
|||
UpdateRequest request = (UpdateRequest) invocation.getArguments()[0];
|
||||
try (
|
||||
XContentParser parser = XContentFactory.xContent(XContentType.JSON)
|
||||
.createParser(
|
||||
NamedXContentRegistry.EMPTY,
|
||||
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
|
||||
request.doc().source().streamInput()
|
||||
)
|
||||
.createParser(XContentParserConfiguration.EMPTY, request.doc().source().streamInput())
|
||||
) {
|
||||
Map<String, Object> map = parser.map();
|
||||
Map<String, String> state = ObjectPath.eval("status.state", map);
|
||||
|
|
|
@ -13,13 +13,12 @@ import org.elasticsearch.common.collect.MapBuilder;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.Maps;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xcontent.DeprecationHandler;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.ObjectPath;
|
||||
import org.elasticsearch.xcontent.ToXContent;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xcontent.XContentFactory;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
import org.elasticsearch.xpack.core.watcher.execution.WatchExecutionContext;
|
||||
import org.elasticsearch.xpack.core.watcher.support.xcontent.WatcherParams;
|
||||
|
@ -356,7 +355,7 @@ public class HttpInputTests extends ESTestCase {
|
|||
BytesReference bytes = BytesReference.bytes(builder);
|
||||
try (
|
||||
XContentParser parser = XContentFactory.xContent(XContentType.JSON)
|
||||
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, bytes.streamInput())
|
||||
.createParser(XContentParserConfiguration.EMPTY, bytes.streamInput())
|
||||
) {
|
||||
Map<String, Object> data = parser.map();
|
||||
String reason = ObjectPath.eval("error.reason", data);
|
||||
|
|
|
@ -26,12 +26,12 @@ import org.elasticsearch.search.builder.SearchSourceBuilder;
|
|||
import org.elasticsearch.search.internal.InternalSearchResponse;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.xcontent.DeprecationHandler;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.ToXContent;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xcontent.XContentFactory;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
import org.elasticsearch.xpack.core.watcher.execution.WatchExecutionContext;
|
||||
import org.elasticsearch.xpack.core.watcher.input.Input;
|
||||
|
@ -209,11 +209,7 @@ public class SearchInputTests extends ESTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
XContentParser parser = XContentFactory.xContent(XContentType.JSON)
|
||||
.createParser(
|
||||
NamedXContentRegistry.EMPTY,
|
||||
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
|
||||
BytesReference.bytes(builder).streamInput()
|
||||
)
|
||||
.createParser(XContentParserConfiguration.EMPTY, BytesReference.bytes(builder).streamInput())
|
||||
) {
|
||||
|
||||
parser.nextToken(); // advance past the first starting object
|
||||
|
|
|
@ -26,11 +26,10 @@ import org.elasticsearch.rest.action.search.RestSearchAction;
|
|||
import org.elasticsearch.test.StreamsUtils;
|
||||
import org.elasticsearch.test.rest.ESRestTestCase;
|
||||
import org.elasticsearch.upgrades.AbstractFullClusterRestartTestCase;
|
||||
import org.elasticsearch.xcontent.DeprecationHandler;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.ObjectPath;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParserConfiguration;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
import org.elasticsearch.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken;
|
||||
|
@ -629,11 +628,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
|||
XContentType xContentType = XContentType.fromMediaType(response.getEntity().getContentType().getValue());
|
||||
try (
|
||||
XContentParser parser = xContentType.xContent()
|
||||
.createParser(
|
||||
NamedXContentRegistry.EMPTY,
|
||||
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
|
||||
response.getEntity().getContent()
|
||||
)
|
||||
.createParser(XContentParserConfiguration.EMPTY, response.getEntity().getContent())
|
||||
) {
|
||||
assertEquals(new SnapshotLifecycleStats(), SnapshotLifecycleStats.parse(parser));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue