Uploaded image for project: 'Commons Collections'
  1. Commons Collections
  2. COLLECTIONS-850

testMultiValuedMapIterator is non-deterministic

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 4.4
    • 4.5.0-M1
    • Map
    • None

    Description

      Overview of PR 
      This PR proposes a fix for the following tests:

      • org.apache.commons.collections4.multimap.TransformedMultiValuedMapTest.testMultiValuedMapIterator
      • org.apache.commons.collections4.multimap.ArrayListValuedHashMapTest.testMultiValuedMapIterator

      Problem:
      In this test, a multivalued map is defined and an iterator is defined on top of that. The test is flaky since the order inside the multivalued map is not maintained.
      Since the order is not maintained, the iterator can have any one key of the three keys for this test ( one, two, three) in random fashion. This flakiness was identified by the nondex tool created by the researchers of UIUC.

      Fix:

      To maintain order, we can implement a TreeMap or a LinkedHashMap but that will change the base code and affect all other entities related to this.
      This PR proposes a fix inside the test while keeping the test logic intact. Since the order is not maintained, we check for the iterator's next value to either be one of the keys and if it is, we check the original assert statements. We follow the same approach to assert all the cases.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              ar80 Anirudh Ragavender
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: