Call createParser with deprecation handler (elastic/x-pack-elasticsearch#3943)

There are only two remaining callers from x-pack that don't pass the deprecation
handler in.

Relates to elastic/x-pack-elasticsearch#28504

Original commit: elastic/x-pack-elasticsearch@cb542613fd
This commit is contained in:
Lee Hinman 2018-02-15 15:38:25 -07:00 committed by GitHub
parent bc150c2521
commit fbd9d6c7f5
2 changed files with 6 additions and 2 deletions

View File

@ -10,6 +10,7 @@ import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.NamedXContentRegistry;
import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
@ -58,7 +59,8 @@ public class TriggeredWatch implements ToXContentObject {
public TriggeredWatch parse(String id, long version, BytesReference source) { public TriggeredWatch parse(String id, long version, BytesReference source) {
// EMPTY is safe here because we never use namedObject // EMPTY is safe here because we never use namedObject
try (XContentParser parser = XContentHelper.createParser(NamedXContentRegistry.EMPTY, source)) { try (XContentParser parser = XContentHelper
.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, source)) {
return parse(id, version, parser); return parse(id, version, parser);
} catch (IOException e) { } catch (IOException e) {
throw new ElasticsearchException("unable to parse watch record", e); throw new ElasticsearchException("unable to parse watch record", e);

View File

@ -13,6 +13,7 @@ import org.elasticsearch.client.Client;
import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.NamedXContentRegistry;
import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
@ -84,7 +85,8 @@ public class ExecutableSearchInput extends ExecutableInput<SearchInput, SearchIn
if (input.getExtractKeys() != null) { if (input.getExtractKeys() != null) {
BytesReference bytes = XContentHelper.toXContent(response, XContentType.JSON, false); BytesReference bytes = XContentHelper.toXContent(response, XContentType.JSON, false);
// EMPTY is safe here because we never use namedObject // EMPTY is safe here because we never use namedObject
try (XContentParser parser = XContentHelper.createParser(NamedXContentRegistry.EMPTY, bytes)) { try (XContentParser parser = XContentHelper
.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, bytes)) {
Map<String, Object> filteredKeys = XContentFilterKeysUtils.filterMapOrdered(input.getExtractKeys(), parser); Map<String, Object> filteredKeys = XContentFilterKeysUtils.filterMapOrdered(input.getExtractKeys(), parser);
payload = new Payload.Simple(filteredKeys); payload = new Payload.Simple(filteredKeys);
} }