Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Invalid
-
4.4
-
None
Description
Problem
The testToString() function that is being implemented by multiple classes and is nondeterministic.
The following classes implement this function-
- org.apache.commons.collections4.multimap.TransformedMultiValuedMapTest.testToString
- org.apache.commons.collections4.multimap.HashSetValuedHashMapTest.testToString
- org.apache.commons.collections4.multimap.ArrayListValuedHashMapTest.testToString
Fix
This test asserts map.toString() is equal to a hardcoded combination of strings namely -
{A=[X, Y, Z], B=[U, V, W]} {B=[U, V, W], A=[X, Y, Z]}
where the map is of the type MultiValuedMap. Here the map.toString() might return _
{B=[U, V, W], A=[X, Y, Z]}_ for the LHS and {{A=[X, Y, Z], B=[U, V, W]} for the RHS which can let the test fail at times.
The toString() function is not inherently flaky and thus is not the root cause of the issue. The initialization of MultiValuedMap with makeObject() is what causes the issue as this can change the order of the keys.
Attachments
Issue Links
- links to