Move more XContent.createParser calls to non-deprecated version (#28670)
* Move more XContent.createParser calls to non-deprecated version This moves more of the callers to pass in the DeprecationHandler. Relates to #28504 * Use parser's deprecation handler where available
This commit is contained in:
parent
53c38cc8fe
commit
7c1f5f5054
|
@ -29,6 +29,7 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
|||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
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;
|
||||
|
@ -108,7 +109,8 @@ public class TransportSearchTemplateAction extends HandledTransportAction<Search
|
|||
return null;
|
||||
}
|
||||
|
||||
try (XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser(xContentRegistry, source)) {
|
||||
try (XContentParser parser = XContentFactory.xContent(XContentType.JSON)
|
||||
.createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, source)) {
|
||||
SearchSourceBuilder builder = SearchSourceBuilder.searchSource();
|
||||
builder.parseXContent(parser);
|
||||
builder.explain(searchTemplateRequest.isExplain());
|
||||
|
|
|
@ -57,6 +57,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
|||
import org.elasticsearch.common.logging.DeprecationLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.lucene.search.Queries;
|
||||
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.XContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
@ -731,8 +732,9 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
|
|||
BytesRef qbSource = binaryDocValues.binaryValue();
|
||||
if (qbSource.length > 0) {
|
||||
XContent xContent = PercolatorFieldMapper.QUERY_BUILDER_CONTENT_TYPE.xContent();
|
||||
try (XContentParser sourceParser = xContent.createParser(context.getXContentRegistry(), qbSource.bytes,
|
||||
qbSource.offset, qbSource.length)) {
|
||||
try (XContentParser sourceParser = xContent
|
||||
.createParser(context.getXContentRegistry(), LoggingDeprecationHandler.INSTANCE,
|
||||
qbSource.bytes, qbSource.offset, qbSource.length)) {
|
||||
return parseQuery(context, mapUnmappedFieldsAsString, sourceParser);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.lucene.util.LuceneTestCase;
|
|||
import org.elasticsearch.Build;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.cluster.ClusterModule;
|
||||
import org.elasticsearch.common.xcontent.DeprecationHandler;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
@ -90,6 +91,7 @@ public class WildflyIT extends LuceneTestCase {
|
|||
XContentParser parser =
|
||||
JsonXContent.jsonXContent.createParser(
|
||||
new NamedXContentRegistry(ClusterModule.getNamedXWriteables()),
|
||||
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
|
||||
response.getEntity().getContent())) {
|
||||
final Map<String, Object> map = parser.map();
|
||||
assertThat(map.get("first_name"), equalTo("John"));
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.common.Strings;
|
|||
import org.elasticsearch.common.component.AbstractComponent;
|
||||
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.XContentHelper;
|
||||
|
@ -120,7 +121,8 @@ public class AliasValidator extends AbstractComponent {
|
|||
public void validateAliasFilter(String alias, String filter, QueryShardContext queryShardContext,
|
||||
NamedXContentRegistry xContentRegistry) {
|
||||
assert queryShardContext != null;
|
||||
try (XContentParser parser = XContentFactory.xContent(filter).createParser(xContentRegistry, filter)) {
|
||||
try (XContentParser parser = XContentFactory.xContent(filter)
|
||||
.createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, filter)) {
|
||||
validateAliasFilter(parser, queryShardContext);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("failed to parse filter for alias [" + alias + "]", e);
|
||||
|
@ -135,7 +137,8 @@ public class AliasValidator extends AbstractComponent {
|
|||
public void validateAliasFilter(String alias, byte[] filter, QueryShardContext queryShardContext,
|
||||
NamedXContentRegistry xContentRegistry) {
|
||||
assert queryShardContext != null;
|
||||
try (XContentParser parser = XContentFactory.xContent(filter).createParser(xContentRegistry, filter)) {
|
||||
try (XContentParser parser = XContentFactory.xContent(filter)
|
||||
.createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, filter)) {
|
||||
validateAliasFilter(parser, queryShardContext);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("failed to parse filter for alias [" + alias + "]", e);
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.elasticsearch.common.unit.RatioValue;
|
|||
import org.elasticsearch.common.unit.SizeValue;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.DeprecationHandler;
|
||||
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.ToXContentFragment;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
@ -1116,7 +1117,8 @@ public final class Settings implements ToXContentFragment {
|
|||
* Loads settings from the actual string content that represents them using {@link #fromXContent(XContentParser)}
|
||||
*/
|
||||
public Builder loadFromSource(String source, XContentType xContentType) {
|
||||
try (XContentParser parser = XContentFactory.xContent(xContentType).createParser(NamedXContentRegistry.EMPTY, source)) {
|
||||
try (XContentParser parser = XContentFactory.xContent(xContentType)
|
||||
.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, source)) {
|
||||
this.put(fromXContent(parser, true, true));
|
||||
} catch (Exception e) {
|
||||
throw new SettingsException("Failed to load settings from [" + source + "]", e);
|
||||
|
|
|
@ -77,8 +77,8 @@ public class ParseFieldRegistry<T> {
|
|||
* @return The value being looked up. Never null.
|
||||
* @throws ParsingException if the named thing isn't in the registry or the name was deprecated and deprecated names aren't supported.
|
||||
*/
|
||||
public T lookup(String name, XContentLocation xContentLocation) {
|
||||
T value = lookupReturningNullIfNotFound(name);
|
||||
public T lookup(String name, XContentLocation xContentLocation, DeprecationHandler deprecationHandler) {
|
||||
T value = lookupReturningNullIfNotFound(name, deprecationHandler);
|
||||
if (value == null) {
|
||||
throw new ParsingException(xContentLocation, "no [" + registryName + "] registered for [" + name + "]");
|
||||
}
|
||||
|
@ -92,14 +92,14 @@ public class ParseFieldRegistry<T> {
|
|||
* @return The value being looked up or null if it wasn't found.
|
||||
* @throws ParsingException if the named thing isn't in the registry or the name was deprecated and deprecated names aren't supported.
|
||||
*/
|
||||
public T lookupReturningNullIfNotFound(String name) {
|
||||
public T lookupReturningNullIfNotFound(String name, DeprecationHandler deprecationHandler) {
|
||||
Tuple<ParseField, T> parseFieldAndValue = registry.get(name);
|
||||
if (parseFieldAndValue == null) {
|
||||
return null;
|
||||
}
|
||||
ParseField parseField = parseFieldAndValue.v1();
|
||||
T value = parseFieldAndValue.v2();
|
||||
boolean match = parseField.match(name, LoggingDeprecationHandler.INSTANCE);
|
||||
boolean match = parseField.match(name, deprecationHandler);
|
||||
//this is always expected to match, ParseField is useful for deprecation warnings etc. here
|
||||
assert match : "ParseField did not match registered name [" + name + "][" + registryName + "]";
|
||||
return value;
|
||||
|
|
|
@ -149,17 +149,6 @@ public interface XContent {
|
|||
return createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a parser over the provided bytes using
|
||||
* {@link LoggingDeprecationHandler}.
|
||||
* @deprecated This is a temporary shim so we can migrate all calls to createParser incrementally.
|
||||
* Use {@link #createParser(NamedXContentRegistry, DeprecationHandler, byte[], int, int)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
default XContentParser createParser(NamedXContentRegistry xContentRegistry, byte[] data, int offset, int length) throws IOException {
|
||||
return createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, data, offset, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a parser over the provided bytes using
|
||||
* {@link LoggingDeprecationHandler}.
|
||||
|
|
|
@ -71,7 +71,7 @@ public class XContentHelper {
|
|||
}
|
||||
return XContentFactory.xContent(xContentType).createParser(xContentRegistry, deprecationHandler, compressedInput);
|
||||
} else {
|
||||
return xContentType.xContent().createParser(xContentRegistry, bytes.streamInput());
|
||||
return xContentType.xContent().createParser(xContentRegistry, deprecationHandler, bytes.streamInput());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,8 @@ public class XContentHelper {
|
|||
*/
|
||||
public static Map<String, Object> convertToMap(XContent xContent, String string, boolean ordered) throws ElasticsearchParseException {
|
||||
// It is safe to use EMPTY here because this never uses namedObject
|
||||
try (XContentParser parser = xContent.createParser(NamedXContentRegistry.EMPTY, string)) {
|
||||
try (XContentParser parser = xContent.createParser(NamedXContentRegistry.EMPTY,
|
||||
DeprecationHandler.THROW_UNSUPPORTED_OPERATION, string)) {
|
||||
return ordered ? parser.mapOrdered() : parser.map();
|
||||
} catch (IOException e) {
|
||||
throw new ElasticsearchParseException("Failed to parse content to map", e);
|
||||
|
@ -131,7 +132,8 @@ public class XContentHelper {
|
|||
public static Map<String, Object> convertToMap(XContent xContent, InputStream input, boolean ordered)
|
||||
throws ElasticsearchParseException {
|
||||
// It is safe to use EMPTY here because this never uses namedObject
|
||||
try (XContentParser parser = xContent.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, input)) {
|
||||
try (XContentParser parser = xContent.createParser(NamedXContentRegistry.EMPTY,
|
||||
DeprecationHandler.THROW_UNSUPPORTED_OPERATION, input)) {
|
||||
return ordered ? parser.mapOrdered() : parser.map();
|
||||
} catch (IOException e) {
|
||||
throw new ElasticsearchParseException("Failed to parse content to map", e);
|
||||
|
@ -161,7 +163,7 @@ public class XContentHelper {
|
|||
|
||||
// It is safe to use EMPTY here because this never uses namedObject
|
||||
try (XContentParser parser = XContentFactory.xContent(xContentType).createParser(NamedXContentRegistry.EMPTY,
|
||||
LoggingDeprecationHandler.INSTANCE, bytes.streamInput())) {
|
||||
DeprecationHandler.THROW_UNSUPPORTED_OPERATION, bytes.streamInput())) {
|
||||
parser.nextToken();
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
if (prettyPrint) {
|
||||
|
|
|
@ -31,6 +31,7 @@ import com.fasterxml.jackson.core.util.JsonGeneratorDelegate;
|
|||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.io.Streams;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.XContent;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
|
@ -314,7 +315,8 @@ public class JsonXContentGenerator implements XContentGenerator {
|
|||
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).createParser(NamedXContentRegistry.EMPTY, content)) {
|
||||
try (XContentParser parser = XContentFactory.xContent(contentType)
|
||||
.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, content)) {
|
||||
parser.nextToken();
|
||||
writeFieldName(name);
|
||||
copyCurrentStructure(parser);
|
||||
|
@ -392,7 +394,8 @@ public class JsonXContentGenerator implements XContentGenerator {
|
|||
protected void copyRawValue(BytesReference content, XContent xContent) throws IOException {
|
||||
// EMPTY is safe here because we never call namedObject
|
||||
try (StreamInput input = content.streamInput();
|
||||
XContentParser parser = xContent.createParser(NamedXContentRegistry.EMPTY, input)) {
|
||||
XContentParser parser = xContent
|
||||
.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, input)) {
|
||||
copyCurrentStructure(parser);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.elasticsearch.ExceptionsHelper;
|
|||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
import org.elasticsearch.common.lucene.store.IndexOutputOutputStream;
|
||||
import org.elasticsearch.common.lucene.store.InputStreamIndexInput;
|
||||
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
|
@ -192,8 +193,9 @@ public abstract class MetaDataStateFormat<T> {
|
|||
long filePointer = indexInput.getFilePointer();
|
||||
long contentSize = indexInput.length() - CodecUtil.footerLength() - filePointer;
|
||||
try (IndexInput slice = indexInput.slice("state_xcontent", filePointer, contentSize)) {
|
||||
try (XContentParser parser = XContentFactory.xContent(FORMAT).createParser(namedXContentRegistry,
|
||||
new InputStreamIndexInput(slice, contentSize))) {
|
||||
try (XContentParser parser = XContentFactory.xContent(FORMAT)
|
||||
.createParser(namedXContentRegistry, LoggingDeprecationHandler.INSTANCE,
|
||||
new InputStreamIndexInput(slice, contentSize))) {
|
||||
return fromXContent(parser);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.elasticsearch.Version;
|
|||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.compress.CompressedXContent;
|
||||
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
@ -162,7 +163,8 @@ public class DocumentMapperParser {
|
|||
|
||||
private Tuple<String, Map<String, Object>> extractMapping(String type, String source) throws MapperParsingException {
|
||||
Map<String, Object> root;
|
||||
try (XContentParser parser = XContentType.JSON.xContent().createParser(xContentRegistry, source)) {
|
||||
try (XContentParser parser = XContentType.JSON.xContent()
|
||||
.createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, source)) {
|
||||
root = parser.mapOrdered();
|
||||
} catch (Exception e) {
|
||||
throw new MapperParsingException("failed to parse mapping definition", e);
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.elasticsearch.common.logging.Loggers;
|
|||
import org.elasticsearch.common.regex.Regex;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Setting.Property;
|
||||
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
@ -200,7 +201,8 @@ public class MapperService extends AbstractIndexComponent implements Closeable {
|
|||
* Parses the mappings (formatted as JSON) into a map
|
||||
*/
|
||||
public static Map<String, Object> parseMapping(NamedXContentRegistry xContentRegistry, String mappingSource) throws Exception {
|
||||
try (XContentParser parser = XContentType.JSON.xContent().createParser(xContentRegistry, mappingSource)) {
|
||||
try (XContentParser parser = XContentType.JSON.xContent()
|
||||
.createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, mappingSource)) {
|
||||
return parser.map();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.common.Strings;
|
|||
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.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
@ -158,7 +159,8 @@ public class WrapperQueryBuilder extends AbstractQueryBuilder<WrapperQueryBuilde
|
|||
|
||||
@Override
|
||||
protected QueryBuilder doRewrite(QueryRewriteContext context) throws IOException {
|
||||
try (XContentParser qSourceParser = XContentFactory.xContent(source).createParser(context.getXContentRegistry(), source)) {
|
||||
try (XContentParser qSourceParser = XContentFactory.xContent(source)
|
||||
.createParser(context.getXContentRegistry(), LoggingDeprecationHandler.INSTANCE, source)) {
|
||||
|
||||
final QueryBuilder queryBuilder = parseInnerQueryBuilder(qSourceParser).rewrite(context);
|
||||
if (boost() != DEFAULT_BOOST || queryName() != null) {
|
||||
|
|
|
@ -62,6 +62,7 @@ import org.elasticsearch.common.unit.TimeValue;
|
|||
import org.elasticsearch.common.util.BigArrays;
|
||||
import org.elasticsearch.common.util.concurrent.EsExecutors;
|
||||
import org.elasticsearch.common.util.iterable.Iterables;
|
||||
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
@ -1236,7 +1237,8 @@ public class IndicesService extends AbstractLifecycleComponent
|
|||
/* Being static, parseAliasFilter doesn't have access to whatever guts it needs to parse a query. Instead of passing in a bunch
|
||||
* of dependencies we pass in a function that can perform the parsing. */
|
||||
CheckedFunction<byte[], QueryBuilder, IOException> filterParser = bytes -> {
|
||||
try (XContentParser parser = XContentFactory.xContent(bytes).createParser(xContentRegistry, bytes)) {
|
||||
try (XContentParser parser = XContentFactory.xContent(bytes)
|
||||
.createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, bytes)) {
|
||||
return parseInnerQueryBuilder(parser);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.elasticsearch.search.aggregations.bucket.significant;
|
|||
import org.elasticsearch.common.ParseField;
|
||||
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.ObjectParser;
|
||||
import org.elasticsearch.common.xcontent.ParseFieldRegistry;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
@ -96,7 +97,7 @@ public class SignificantTermsAggregationBuilder extends ValuesSourceAggregationB
|
|||
aggregationParser.declareObject(SignificantTermsAggregationBuilder::significanceHeuristic,
|
||||
(p, context) -> {
|
||||
SignificanceHeuristicParser significanceHeuristicParser = significanceHeuristicParserRegistry
|
||||
.lookupReturningNullIfNotFound(name);
|
||||
.lookupReturningNullIfNotFound(name, p.getDeprecationHandler());
|
||||
return significanceHeuristicParser.parse(p);
|
||||
},
|
||||
new ParseField(name));
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.search.aggregations.bucket.significant;
|
|||
import org.elasticsearch.common.ParseField;
|
||||
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.ObjectParser;
|
||||
import org.elasticsearch.common.xcontent.ParseFieldRegistry;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
@ -111,7 +112,7 @@ public class SignificantTextAggregationBuilder extends AbstractAggregationBuilde
|
|||
PARSER.declareObject(SignificantTextAggregationBuilder::significanceHeuristic,
|
||||
(p, context) -> {
|
||||
SignificanceHeuristicParser significanceHeuristicParser = significanceHeuristicParserRegistry
|
||||
.lookupReturningNullIfNotFound(name);
|
||||
.lookupReturningNullIfNotFound(name, p.getDeprecationHandler());
|
||||
return significanceHeuristicParser.parse(p);
|
||||
}, new ParseField(name));
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.elasticsearch.common.ParseField;
|
|||
import org.elasticsearch.common.ParsingException;
|
||||
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.ParseFieldRegistry;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
@ -402,7 +403,8 @@ public class MovAvgPipelineAggregationBuilder extends AbstractPipelineAggregatio
|
|||
factory.predict(predict);
|
||||
}
|
||||
if (model != null) {
|
||||
MovAvgModel.AbstractModelParser modelParser = movingAverageMdelParserRegistry.lookup(model, parser.getTokenLocation());
|
||||
MovAvgModel.AbstractModelParser modelParser = movingAverageMdelParserRegistry.lookup(model,
|
||||
parser.getTokenLocation(), parser.getDeprecationHandler());
|
||||
MovAvgModel movAvgModel;
|
||||
try {
|
||||
movAvgModel = modelParser.parse(settings, pipelineAggregatorName, factory.window());
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.lucene.util.BytesRefBuilder;
|
|||
import org.apache.lucene.util.CharsRefBuilder;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.text.Text;
|
||||
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.query.AbstractQueryBuilder;
|
||||
|
@ -115,8 +116,8 @@ public final class PhraseSuggester extends Suggester<PhraseSuggestionContext> {
|
|||
vars.put(SUGGESTION_TEMPLATE_VAR_NAME, spare.toString());
|
||||
QueryShardContext shardContext = suggestion.getShardContext();
|
||||
final String querySource = scriptFactory.newInstance(vars).execute();
|
||||
try (XContentParser parser = XContentFactory.xContent(querySource).createParser(shardContext.getXContentRegistry(),
|
||||
querySource)) {
|
||||
try (XContentParser parser = XContentFactory.xContent(querySource)
|
||||
.createParser(shardContext.getXContentRegistry(), LoggingDeprecationHandler.INSTANCE, querySource)) {
|
||||
QueryBuilder innerQueryBuilder = AbstractQueryBuilder.parseInnerQueryBuilder(parser);
|
||||
final ParsedQuery parsedQuery = shardContext.toQuery(innerQueryBuilder);
|
||||
collateMatch = Lucene.exists(searcher, parsedQuery.query());
|
||||
|
|
|
@ -753,7 +753,8 @@ public abstract class BaseXContentTestCase extends ESTestCase {
|
|||
generator.writeEndObject();
|
||||
}
|
||||
|
||||
XContentParser parser = xcontentType().xContent().createParser(NamedXContentRegistry.EMPTY, os.toByteArray());
|
||||
XContentParser parser = xcontentType().xContent()
|
||||
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, os.toByteArray());
|
||||
assertEquals(Token.START_OBJECT, parser.nextToken());
|
||||
assertEquals(Token.FIELD_NAME, parser.nextToken());
|
||||
assertEquals("bar", parser.currentName());
|
||||
|
@ -787,7 +788,8 @@ public abstract class BaseXContentTestCase extends ESTestCase {
|
|||
generator.writeRawValue(new BytesArray(rawData));
|
||||
}
|
||||
|
||||
XContentParser parser = xcontentType().xContent().createParser(NamedXContentRegistry.EMPTY, os.toByteArray());
|
||||
XContentParser parser = xcontentType().xContent()
|
||||
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, os.toByteArray());
|
||||
assertEquals(Token.START_OBJECT, parser.nextToken());
|
||||
assertEquals(Token.FIELD_NAME, parser.nextToken());
|
||||
assertEquals("foo", parser.currentName());
|
||||
|
@ -803,7 +805,8 @@ public abstract class BaseXContentTestCase extends ESTestCase {
|
|||
generator.writeEndObject();
|
||||
}
|
||||
|
||||
parser = xcontentType().xContent().createParser(NamedXContentRegistry.EMPTY, os.toByteArray());
|
||||
parser = xcontentType().xContent()
|
||||
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, os.toByteArray());
|
||||
assertEquals(Token.START_OBJECT, parser.nextToken());
|
||||
assertEquals(Token.FIELD_NAME, parser.nextToken());
|
||||
assertEquals("test", parser.currentName());
|
||||
|
@ -831,7 +834,8 @@ public abstract class BaseXContentTestCase extends ESTestCase {
|
|||
generator.flush();
|
||||
byte[] serialized = os.toByteArray();
|
||||
|
||||
XContentParser parser = xcontentType().xContent().createParser(NamedXContentRegistry.EMPTY, serialized);
|
||||
XContentParser parser = xcontentType().xContent()
|
||||
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, serialized);
|
||||
Map<String, Object> map = parser.map();
|
||||
assertEquals("bar", map.get("foo"));
|
||||
assertEquals(bigInteger, map.get("bigint"));
|
||||
|
@ -1030,7 +1034,8 @@ public abstract class BaseXContentTestCase extends ESTestCase {
|
|||
assertEquals("Unknown namedObject category [java.lang.String]", e.getMessage());
|
||||
}
|
||||
{
|
||||
XContentParser emptyRegistryParser = xcontentType().xContent().createParser(NamedXContentRegistry.EMPTY, new byte[] {});
|
||||
XContentParser emptyRegistryParser = xcontentType().xContent()
|
||||
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, new byte[] {});
|
||||
Exception e = expectThrows(ElasticsearchException.class,
|
||||
() -> emptyRegistryParser.namedObject(String.class, "doesn't matter", null));
|
||||
assertEquals("namedObject is not supported for this parser", e.getMessage());
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
|||
import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.DeprecationHandler;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
|
@ -159,7 +160,8 @@ public class ShardSearchTransportRequestTests extends AbstractSearchTestCase {
|
|||
|
||||
public QueryBuilder aliasFilter(IndexMetaData indexMetaData, String... aliasNames) {
|
||||
CheckedFunction<byte[], QueryBuilder, IOException> filterParser = bytes -> {
|
||||
try (XContentParser parser = XContentFactory.xContent(bytes).createParser(xContentRegistry(), bytes)) {
|
||||
try (XContentParser parser = XContentFactory.xContent(bytes)
|
||||
.createParser(xContentRegistry(), DeprecationHandler.THROW_UNSUPPORTED_OPERATION, bytes)) {
|
||||
return parseInnerQueryBuilder(parser);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.search.suggest;
|
|||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.text.Text;
|
||||
import org.elasticsearch.common.xcontent.DeprecationHandler;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContent;
|
||||
|
@ -174,7 +175,8 @@ public class SuggestionTests extends ESTestCase {
|
|||
+ "\"collate_match\":true}]"
|
||||
+ "}]"
|
||||
+ "}";
|
||||
try (XContentParser parser = xContent.createParser(xContentRegistry(), suggestionString)) {
|
||||
try (XContentParser parser = xContent.createParser(xContentRegistry(),
|
||||
DeprecationHandler.THROW_UNSUPPORTED_OPERATION, suggestionString)) {
|
||||
ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.nextToken(), parser::getTokenLocation);
|
||||
ensureExpectedToken(XContentParser.Token.FIELD_NAME, parser.nextToken(), parser::getTokenLocation);
|
||||
ensureExpectedToken(XContentParser.Token.START_ARRAY, parser.nextToken(), parser::getTokenLocation);
|
||||
|
|
|
@ -53,6 +53,7 @@ import org.elasticsearch.common.settings.Setting;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsModule;
|
||||
import org.elasticsearch.common.unit.Fuzziness;
|
||||
import org.elasticsearch.common.xcontent.DeprecationHandler;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
@ -404,8 +405,9 @@ public abstract class AbstractQueryTestCase<QB extends AbstractQueryBuilder<QB>>
|
|||
|
||||
BytesStreamOutput out = new BytesStreamOutput();
|
||||
try (
|
||||
XContentGenerator generator = XContentType.JSON.xContent().createGenerator(out);
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, query);
|
||||
XContentGenerator generator = XContentType.JSON.xContent().createGenerator(out);
|
||||
XContentParser parser = JsonXContent.jsonXContent
|
||||
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, query);
|
||||
) {
|
||||
int objectIndex = -1;
|
||||
Deque<String> levels = new LinkedList<>();
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.http.client.methods.HttpHead;
|
|||
import org.apache.http.util.EntityUtils;
|
||||
import org.elasticsearch.client.Response;
|
||||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
|
@ -114,7 +115,8 @@ public class ClientYamlTestResponse {
|
|||
} else {
|
||||
//if the body is in a binary format and gets requested as a string (e.g. to log a test failure), we convert it to json
|
||||
try (XContentBuilder jsonBuilder = XContentFactory.jsonBuilder()) {
|
||||
try (XContentParser parser = bodyContentType.xContent().createParser(NamedXContentRegistry.EMPTY, body)) {
|
||||
try (XContentParser parser = bodyContentType.xContent()
|
||||
.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, body)) {
|
||||
jsonBuilder.copyCurrentStructure(parser);
|
||||
}
|
||||
bodyAsString = jsonBuilder.string();
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.common.Strings;
|
|||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.logging.DeprecationLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.xcontent.DeprecationHandler;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.XContentLocation;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
@ -128,7 +129,8 @@ public class DoSection implements ExecutableSection {
|
|||
} else if (token.isValue()) {
|
||||
if ("body".equals(paramName)) {
|
||||
String body = parser.text();
|
||||
XContentParser bodyParser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, body);
|
||||
XContentParser bodyParser = JsonXContent.jsonXContent
|
||||
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, body);
|
||||
//multiple bodies are supported e.g. in case of bulk provided as a whole string
|
||||
while(bodyParser.nextToken() != null) {
|
||||
apiCallSection.addBody(bodyParser.mapOrdered());
|
||||
|
|
Loading…
Reference in New Issue