Open wang3820 opened 9 months ago
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.
Flakiness
Nondex was used to check and locate the flakiness in the test. The test can be reproduced using the following command:
Issue
In the
toString
method,getDeclaredFields()
was called to iterate through all the fields in this class. However,getDeclaredFields()
does not guarantee the order of elements returned, according to the Java Documentation: The elements in the returned array are not sorted and are not in any particular order.Fix
Since the output array of
getDeclaredFields()
is not in any particular order, the fix sorts the array of fields returned bygetDeclaredFields()
by field name and then convert the array to string with the original format, except that fields are sorted by name. In the testcase, the expected string is also sorted by field names. This way this testcase constantly passes, resolving any flakiness.