HIVE-28603 Fixing Multiple Flaky tests in module serde which are due to non determinism #5527
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Sorting the fields in function
getDeclaredNonStaticFields()
in ObjectInspectorUtils.java class in order to make the function deterministic. The below flaky tests will be fixed by this.Why are the changes needed?
Multiple flaky tests were detected in serde module while trying to run the tests using the nondex tool. NonDex is a tool for detecting and debugging wrong assumptions on under-determined Java APIs.
Steps to reproduce flakiness using nondex -
ERROR logs:
Reason for Failure
The method getDeclaredNonStaticFields(Class<?> c) in class ObjectInspectorUtils.java uses class.getDeclaredFields() method which is nondeterministic as per java docs.
Field[] f = c.getDeclaredFields();
As per the test cases, it is assumed that the return order of the fields will always be the same, which may not be the case.
All the below test cases are impacted because of the same reason :
Does this PR introduce any user-facing change?
No
Is the change a dependency upgrade?
No
How was this patch tested?
The changes were tested by running the unit tests locally. The code is already covered in the above test cases and is actually fixing the flaky tests.
Please let me know if you have any questions or would like to discuss this further for any clarificaitions.