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

Fixed flaky test #3401

Merged
merged 1 commit into from
Nov 17, 2023
Merged

Fixed flaky test #3401

merged 1 commit into from
Nov 17, 2023

Conversation

wang3820
Copy link
Contributor

@wang3820 wang3820 commented Nov 16, 2023

Issue

The root issue is that JSONObject.toJSONString() use HashMap to convert json data into strings. In this case, toJSONString() was called on jvalue and then the output string is compared to a fixed string. Because HashMap does not guarantee the order of elements returned, the two strings could have the same content but in different order, thus the flakiness.

Fix

This flaky test has been fixed through leveraging the Jackson library, which incorporates the JsonNode and ObjectMapper classes. These components are employed for parsing two JSON strings into tree models, which are subsequently compared node by node when assertion is called.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Run mvn clean install apache-rat:check to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
  • If you have a group of commits related to the same change, please squash your commits into one and force push your branch using git rebase -i.
  • Mention the appropriate issue in your description (for example: addresses #123), if applicable.

To make clear that you license your contribution under the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

@hansva hansva merged commit 14bf658 into apache:master Nov 17, 2023
2 checks passed
@wang3820 wang3820 deleted the fix-flaky branch November 18, 2023 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants