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.
Flakiness
Nondex was used to check and locate the flakiness in the test. The test can be reproduced using the following command:
mvn install -pl generator -am -DskipTests mvn -pl generator test -Dtest=com.graphicsfuzz.generator.util.TransformationProbabilitiesTest#testToString mvn -pl generator edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=com.graphicsfuzz.generator.util.TransformationProbabilitiesTest#testToString
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.