You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Anirudh Ragavender (Jira)" <ji...@apache.org> on 2023/10/29 17:15:00 UTC
[jira] [Updated] (COLLECTIONS-848) testToString() is non-deterministic
[ https://issues.apache.org/jira/browse/COLLECTIONS-848?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Anirudh Ragavender updated COLLECTIONS-848:
-------------------------------------------
Description:
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 -
`\{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.
PR: -
was:
h3. Problem
The [testToString() | [https://github.com/anirudh711/commons-collections/blob/35e408717379eed0085cdb29e879209dbadc1ead/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java#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 -
{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.
PR: -
> 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
> Fix For: 4.5
>
>
> 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 -
> `\{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.
> PR: -
--
This message was sent by Atlassian Jira
(v8.20.10#820010)