[jira] [Updated] (COLLECTIONS-804) testCollectionToArray2() is non deterministic
[ https://issues.apache.org/jira/browse/COLLECTIONS-804?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Vivek Gupta updated COLLECTIONS-804: Priority: Major (was: Minor) > testCollectionToArray2() is non deterministic > - > > Key: COLLECTIONS-804 > URL: https://issues.apache.org/jira/browse/COLLECTIONS-804 > Project: Commons Collections > Issue Type: Bug > Components: Collection >Affects Versions: 4.4 >Reporter: Vivek Gupta >Priority: Major > > The test > {{org.apache.commons.collections4.collection.AbstractCollectionTest.testCollectionToArray2()}} > can fail if two {{toArray()}} calls return elements in a different order. > One can check for that using the NonDex tool > ([https://github.com/TestingResearchIllinois/NonDex]). > Bug repoduction: > # Clone the repo and cd into it. > # {{mvn test > -Dtest=org.apache.commons.collections4.bidimap.DualHashBidiMapTest#testCollectionToArray2 > -Drat.skip}} This test will pass. > # {{mvn edu.illinois:nondex-maven-plugin:1.1.2:nondex > -Dtest=org.apache.commons.collections4.bidimap.DualHashBidiMapTest#testCollectionToArray2 > -Drat.skip}} This command runs the NonDex tool on the the test. Near the end > of the output, you will see a summary of test failures, where you will find > {{testCollectionToArray2()}} function listed. > The source of the bug: > The test gets an array representation of the collections and then compares > them, taking the order into account. However, Java Collections need not be > necessarily ordered. Its member function {{toArray()}} also does not > guarantee a deterministic order of the elements in its returned list. As > such, we should ignore the order of the elements in the assertion. > Proposed fix: > We ignore the order of array lists by putting its elements into separate > multisets and then comparing those multisets for equality. Multiset is not a > part of the standard Java library. However, conveniently enough, this > repository already had an implementation of multiset called HashBags, which I > used. -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Updated] (COLLECTIONS-804) testCollectionToArray2() is non deterministic
[ https://issues.apache.org/jira/browse/COLLECTIONS-804?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Vivek Gupta updated COLLECTIONS-804: Affects Version/s: 4.4 > testCollectionToArray2() is non deterministic > - > > Key: COLLECTIONS-804 > URL: https://issues.apache.org/jira/browse/COLLECTIONS-804 > Project: Commons Collections > Issue Type: Bug > Components: Collection >Affects Versions: 4.4 >Reporter: Vivek Gupta >Priority: Minor > > The test > {{org.apache.commons.collections4.collection.AbstractCollectionTest.testCollectionToArray2()}} > can fail if two {{toArray()}} calls return elements in a different order. > One can check for that using the NonDex tool > ([https://github.com/TestingResearchIllinois/NonDex]). > Bug repoduction: > # Clone the repo and cd into it. > # {{mvn test > -Dtest=org.apache.commons.collections4.bidimap.DualHashBidiMapTest#testCollectionToArray2 > -Drat.skip}} This test will pass. > # {{mvn edu.illinois:nondex-maven-plugin:1.1.2:nondex > -Dtest=org.apache.commons.collections4.bidimap.DualHashBidiMapTest#testCollectionToArray2 > -Drat.skip}} This command runs the NonDex tool on the the test. Near the end > of the output, you will see a summary of test failures, where you will find > {{testCollectionToArray2()}} function listed. > The source of the bug: > The test gets an array representation of the collections and then compares > them, taking the order into account. However, Java Collections need not be > necessarily ordered. Its member function {{toArray()}} also does not > guarantee a deterministic order of the elements in its returned list. As > such, we should ignore the order of the elements in the assertion. > Proposed fix: > We ignore the order of array lists by putting its elements into separate > multisets and then comparing those multisets for equality. Multiset is not a > part of the standard Java library. However, conveniently enough, this > repository already had an implementation of multiset called HashBags, which I > used. -- This message was sent by Atlassian Jira (v8.20.1#820001)