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

CollectionUtilsTest.getFromMap() is flaky

    XMLWordPrintableJSON

Details

    Description

      CollectionUtilsTest.getFromMap() is flaky on line 996: assertEquals(expected, found). We can get the following failure:

      [ERROR] CollectionUtilsTest.getFromMap:996 expected:<{oneKey=one, zeroKey=zero}> but was:<{oneKey=one}>

       

      The flakiness is introduced by calls to CollectionUtils.get(expected, 0) and CollectionUtils.get(expected, 1). Because CollectionUtils.get() uses a new Java Iterator each time it is called, it's possible that get(0) != get(0) and get(0) = get(1) in two subsequent calls to the "expected" HashMap. The end result is we may have only added {oneKey=one} or {zeroKey=zero}, but not both, to the "found" HashMap.

      Attachments

        Activity

          People

            Unassigned Unassigned
            xint5 XinT
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 40m
                40m