-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Improve resiliency to formatting JSON in server #48553
Conversation
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.
Pinging @elastic/es-core-infra (:Core/Infra/Core) |
These have moved to PR elastic#48553.
@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 { |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
@elasticmachine run elasticsearch-ci/bwc |
@elasticmachine run elasticsearch-ci/bwc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.
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.
Split out from #48450. Make a number of changes so that JSON in the server directory is more resilient to automatic formatting. This covers:
document using XContent methods. This is sometimes necessary where
a test is comparing some machine-generated JSON with an expected
value.