Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XContent: Factor deprecation handling into callback #28449

Merged

Conversation

nik9000
Copy link
Member

@nik9000 nik9000 commented Jan 30, 2018

Factors the way in which XContent parsing handles deprecated fields
into a callback that is set at parser construction time. The goals here
are:

  1. Remove Log4J as a dependency of XContent so that XContent can be used
    by clients without forcing log4j and our particular deprecation handling
    scheme.
  2. Simplify handling of deprecated fields in tests. Now tests can listen
    directly for the deprecation callback rather than digging through a
    ThreadLocal.

More accurately, this change begins this work. It deprecates a number of
methods, pointing folks to the new versions of those methods that take
DeprecationHandler. The plan is to slowly drop these deprecated
methods. Once they are entirely removed we can remove Log4j as
dependency of XContent.

Replaces #27955.

Factors the way in which XContent parsing handles deprecated fields
into a callback that is set at parser construction time. The goals here
are:
1. Remove Log4J as a dependency of XContent so that XContent can be used
by clients without forcing log4j and our particular deprecation handling
scheme.
2. Simplify handling of deprecated fields in tests. Now tests can listen
directly for the deprecation callback rather than digging through a
ThreadLocal.

More accurately, this change begins this work. It deprecates a number of
methods, pointing folks to the new versions of those methods that take
`DeprecationHandler`. The plan is to slowly drop these deprecated
methods. Once they are entirely removed we can remove Log4j as
dependency of XContent.
@nik9000 nik9000 requested a review from dakrone January 30, 2018 20:55
@nik9000 nik9000 added the review label Jan 30, 2018
Copy link
Member

@dakrone dakrone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, I appreciate you breaking it up so it's easier to digest. I left one cosmetic comment

@@ -95,8 +96,7 @@ public Factory(ScriptService scriptService) {
public ScriptProcessor create(Map<String, Processor.Factory> registry, String processorTag,
Map<String, Object> config) throws Exception {
XContentBuilder builder = XContentBuilder.builder(JsonXContent.jsonXContent).map(config);
JsonXContentParser parser = new JsonXContentParser(NamedXContentRegistry.EMPTY,
JSON_FACTORY.createParser(builder.bytes().streamInput()));
XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, builder.bytes().streamInput());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this one use JsonXContent.jsonXContent.createParser(...) and the one below use XContentType.JSON.xContent().createParser(...) ? They're the same thing so I think we should standardize on one (probably the XContentType one?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose because I'm used to the top one and forgot about the bottom one. I'll make them line up.

@nik9000 nik9000 merged commit 3b6af15 into elastic:master Jan 30, 2018
nik9000 added a commit that referenced this pull request Jan 31, 2018
Factors the way in which XContent parsing handles deprecated fields
into a callback that is set at parser construction time. The goals here
are:
1. Remove Log4J as a dependency of XContent so that XContent can be used
by clients without forcing log4j and our particular deprecation handling
scheme.
2. Simplify handling of deprecated fields in tests. Now tests can listen
directly for the deprecation callback rather than digging through a
ThreadLocal.

More accurately, this change begins this work. It deprecates a number of
methods, pointing folks to the new versions of those methods that take
`DeprecationHandler`. The plan is to slowly drop these deprecated
methods. Once they are entirely removed we can remove Log4j as
dependency of XContent.
dakrone added a commit to dakrone/elasticsearch that referenced this pull request Feb 1, 2018
This commit switches all the modules and server test code to use the
non-deprecated `ParseField.match` method, passing in the logging deprecation
handler.

Relates to elastic#28449
dakrone added a commit to dakrone/elasticsearch that referenced this pull request Feb 1, 2018
This commit switches all the modules and server test code to use the
non-deprecated `ParseField.match` method, passing in the parser's deprecation
handler or the logging deprecation handler when a parser is not available (like
in tests).

Relates to elastic#28449
dakrone added a commit that referenced this pull request Feb 2, 2018
This commit switches all the modules and server test code to use the
non-deprecated `ParseField.match` method, passing in the parser's deprecation
handler or the logging deprecation handler when a parser is not available (like
in tests).

Relates to #28449
dakrone added a commit that referenced this pull request Feb 2, 2018
This commit switches all the modules and server test code to use the
non-deprecated `ParseField.match` method, passing in the parser's deprecation
handler or the logging deprecation handler when a parser is not available (like
in tests).

Relates to #28449
dakrone added a commit to dakrone/elasticsearch that referenced this pull request Feb 2, 2018
This moves away from one of the now-deprecated XContentHelper.createParser
methods in favor of specifying the deprecation logger at parser creation time.

Relates to elastic#28449

Note that this doesn't move all the `createParser` calls because some of them
use the already-deprecated method that doesn't specify the XContentType.
dakrone added a commit that referenced this pull request Feb 5, 2018
* Move to non-deprecated XContentHelper.createParser(...)

This moves away from one of the now-deprecated XContentHelper.createParser
methods in favor of specifying the deprecation logger at parser creation time.

Relates to #28449

Note that this doesn't move all the `createParser` calls because some of them
use the already-deprecated method that doesn't specify the XContentType.

* Remove the deprecated (and now non-needed) createParser method
dakrone added a commit that referenced this pull request Feb 5, 2018
* Move to non-deprecated XContentHelper.createParser(...)

This moves away from one of the now-deprecated XContentHelper.createParser
methods in favor of specifying the deprecation logger at parser creation time.

Relates to #28449

Note that this doesn't move all the `createParser` calls because some of them
use the already-deprecated method that doesn't specify the XContentType.

* Remove the deprecated (and now non-needed) createParser method
@jpountz jpountz added >enhancement :Core/Infra/Core Core issues without another label labels Jun 13, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants