You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2024/03/30 14:22:00 UTC

[jira] [Closed] (COLLECTIONS-848) testToString() is non-deterministic

     [ https://issues.apache.org/jira/browse/COLLECTIONS-848?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary D. Gregory closed COLLECTIONS-848.
---------------------------------------

>  testToString() is non-deterministic
> ------------------------------------
>
>                 Key: COLLECTIONS-848
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-848
>             Project: Commons Collections
>          Issue Type: Bug
>          Components: Map
>    Affects Versions: 4.4
>            Reporter: Anirudh Ragavender
>            Priority: Minor
>              Labels: pull-request-available
>
> h3. Problem
> The [testToString() |#L708-L711]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*
> h3. Fix
> This test asserts map.toString() is equal to a hardcoded combination of strings namely -
> {code:java}
> {A=[X, Y, Z], B=[U, V, W]}
> {B=[U, V, W], A=[X, Y, Z]}
> {code}
> 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.
> PR: [https://github.com/apache/commons-collections/pull/426]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)