This flakiness was identified by the nondex tool created by the researchers of UIUC. The above eight tests fail when run on the nondex tool.
The eight tests, although varied in notion of what is being tested are flaky for the same reason. A json with more than one field is being serialised and being checked with assertEquals. When the json is being serialised, the order is not maintained and assertEquals fails at times when it is different from the true order. This does not occur with json with one element since order is constant.
This means for the test above, the json that is being serilaised is -
{ field:[1] , field2:{"hello":1} }
The serialized output can be either
"{\"field\":[1],\"field2\":{\"hello\":1}}"
"{\"field2\":{\"hello\":1},\"field\":[1]}"
This change in ordering presents itself in different instances in the above eight tests.
Fix:
The proposed fix to use JSONAssert.assertEquals from org.skyscreamer.jsonassert.JSONAssert package which checks the structure of the JSON in the equality and not focus on the order of the field. This provides more granularity and accuracy of how we check JSON value equalities.
PR Overview
The PR proposes a fix for the following tests - com.jsoniter.extra.TestPreciseFloat#test_indirect_encode com.jsoniter.output.TestGson#test_serializeNulls com.jsoniter.output.TestObject#test_omit_default com.jsoniter.output.TestObject#test_omit_null com.jsoniter.output.TestNested#test_map_of_objects com.jsoniter.output.TestNested#test_object_of_array com.jsoniter.output.TestGenerics#test_wildcard com.jsoniter.output.TestObject#test_indention
Build Project
Problem
This flakiness was identified by the nondex tool created by the researchers of UIUC. The above eight tests fail when run on the nondex tool. The eight tests, although varied in notion of what is being tested are flaky for the same reason. A json with more than one field is being serialised and being checked with
assertEquals
. When the json is being serialised, the order is not maintained andassertEquals
fails at times when it is different from the true order. This does not occur with json with one element since order is constant.https://github.com/json-iterator/java/blob/6925cf4c19d313504b416f58a349a36bf563e0e1/src/test/java/com/jsoniter/output/TestGenerics.java#L47-L57
This means for the test above, the json that is being serilaised is -
The serialized output can be either
This change in ordering presents itself in different instances in the above eight tests.
Fix:
The proposed fix to use
JSONAssert.assertEquals
fromorg.skyscreamer.jsonassert.JSONAssert
package which checks the structure of the JSON in the equality and not focus on the order of the field. This provides more granularity and accuracy of how we check JSON value equalities.