Skip to content

Improve resiliency to formatting JSON in server#48553

Merged
pugnascotia merged 6 commits intoelastic:masterfrom
pugnascotia:formatting-fixes-server-json
Oct 30, 2019
Merged

Improve resiliency to formatting JSON in server#48553
pugnascotia merged 6 commits intoelastic:masterfrom
pugnascotia:formatting-fixes-server-json

Conversation

@pugnascotia
Copy link
Copy Markdown
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
@pugnascotia pugnascotia requested a review from rjernst October 26, 2019 14:11
@elasticmachine
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

@elasticmachine run elasticsearch-ci/bwc

@pugnascotia
Copy link
Copy Markdown
Contributor Author

@elasticmachine run elasticsearch-ci/bwc

Copy link
Copy Markdown
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