Skip to content

Conversation

@colings86
Copy link
Contributor

This includes removing ToXContentToBytes

Copy link
Member

@javanna javanna left a comment

Choose a reason for hiding this comment

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

left a couple of comments, thanks for doing this!

import static org.elasticsearch.common.xcontent.XContentParser.Token.END_OBJECT;

public final class InnerHitBuilder extends ToXContentToBytes implements Writeable {
public final class InnerHitBuilder implements Writeable, ToXContentObject {
Copy link
Member

Choose a reason for hiding this comment

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

should we add toString impl to this class now that it doesn't inherit anymore from ToXContentToBytes?

Copy link
Member

Choose a reason for hiding this comment

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

this applies to all the classes that don't extend from ToXCOntentToBytes anymore and don't declare their own toString .

// So we have a stack trace logged somewhere
return "{ \"error\" : \"" + ExceptionsHelper.detailedMessage(e) + "\"}";
}
}
Copy link
Member

Choose a reason for hiding this comment

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

can we use some of the XContentHelper or Strings.toString here instead?

@colings86
Copy link
Contributor Author

@javanna thanks for reviewing, I push two commits that address your comments, could you look again?

@Override
public String toString() {
try {
return XContentHelper.toXContent(this, XContentType.JSON, true).utf8ToString();
Copy link
Member

Choose a reason for hiding this comment

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

Strings.toString already catches IOException. there is a variant of it where you can pass in pretty and himanReadable flags.

Copy link
Member

@javanna javanna left a comment

Choose a reason for hiding this comment

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

LGTM besides the comment I left on using Strings.toString .

@colings86 colings86 merged commit c3cc826 into elastic:master Aug 23, 2017
colings86 added a commit that referenced this pull request Aug 23, 2017
* More XContent migrations

* Removes ToXContentToBytes

* Adds toString to classes that used to extend ToXContentToBytes

* use XContentHelper

* more review comments

* prettify tostring output
colings86 added a commit that referenced this pull request Aug 23, 2017
* More XContent migrations

* Removes ToXContentToBytes

* Adds toString to classes that used to extend ToXContentToBytes

* use XContentHelper

* more review comments

* prettify tostring output
@colings86 colings86 deleted the refactor/toXContentFragments2 branch August 23, 2017 07:21
colings86 added a commit that referenced this pull request Aug 23, 2017
@colings86 colings86 removed the v6.0.0 label Aug 23, 2017
@colings86
Copy link
Contributor Author

Note that this PR is only in merged to master and 6.x as the changes are not compatible with 6.0

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.

3 participants