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

Improve resiliency to formatting JSON in server #48553

Merged
merged 6 commits into from
Oct 30, 2019

Conversation

pugnascotia
Copy link
Contributor

Split out from #48450. Make a number of changes so that JSON in the server directory is more resilient to automatic formatting. This covers:

  • Reformatting multiline JSON to embed whitespace in the strings
  • Add helper method reformatJson(), to strip whitespace from a JSON
    document using XContent methods. This is sometimes necessary where
    a test is comparing some machine-generated JSON with an expected
    value.

Make a number of changes so that JSON in the server directory is more
resilient to automatic formatting. This covers:

   * Reformatting multiline JSON to embed whitespace in the strings
   * Add helper method reformatJson(), to strip whitespace from a JSON
     document using XContent methods. This is sometimes necessary where
     a test is comparing some machine-generated JSON with an expected
     value.
@pugnascotia pugnascotia added :Core/Infra/Core Core issues without another label v8.0.0 v7.6.0 labels Oct 26, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (:Core/Infra/Core)

pugnascotia added a commit to pugnascotia/elasticsearch that referenced this pull request Oct 26, 2019
These have moved to PR elastic#48553.
@pugnascotia
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/2

* @return reformatted JSON
* @throws IOException if the reformatting fails, e.g. because the JSON is not well-formed
*/
public static String reformatJson(String json) throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a name that better reflects what the reformat actually does would be better, something like stripWhitespace maybe ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @atorok, I renamed the method as you suggested.

@pugnascotia
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/bwc

@pugnascotia
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/bwc

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

LGTM

@pugnascotia pugnascotia merged commit 2d3e331 into elastic:master Oct 30, 2019
@pugnascotia pugnascotia deleted the formatting-fixes-server-json branch October 30, 2019 17:10
pugnascotia added a commit to pugnascotia/elasticsearch that referenced this pull request Oct 30, 2019
Make a number of changes so that JSON in the server directory is more
resilient to automatic formatting. This covers:

   * Reformatting multiline JSON to embed whitespace in the strings
   * Add helper method `stripWhitespace()`, to strip whitespace from a JSON
     document using XContent methods. This is sometimes necessary where
     a test is comparing some machine-generated JSON with an expected
     value.
pugnascotia added a commit that referenced this pull request Oct 31, 2019
Backport of #48553. Make a number of changes so that JSON in the server
directory is more resilient to automatic formatting. This covers:

   * Reformatting multiline JSON to embed whitespace in the strings
   * Add helper method `stripWhitespace()`, to strip whitespace from a JSON
     document using XContent methods. This is sometimes necessary where
     a test is comparing some machine-generated JSON with an expected
     value.
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.

6 participants