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 2020/12/05 15:31:00 UTC
[jira] [Commented] (COLLECTIONS-775)
CollectionUtilsTest.getFromMap() is flaky
[ https://issues.apache.org/jira/browse/COLLECTIONS-775?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17244520#comment-17244520 ]
Gary D. Gregory commented on COLLECTIONS-775:
---------------------------------------------
Hi [~xint5]
Merged in git master. I also broke up the test and added a new one for ORDERED maps like {{LinkedHashMap}}.
Please verify and close this ticket.
> CollectionUtilsTest.getFromMap() is flaky
> -----------------------------------------
>
> Key: COLLECTIONS-775
> URL: https://issues.apache.org/jira/browse/COLLECTIONS-775
> Project: Commons Collections
> Issue Type: Bug
> Components: Collection
> Affects Versions: 4.4
> Reporter: XinT
> Priority: Minor
> Labels: pull-request-available, test
> Time Spent: 40m
> Remaining Estimate: 0h
>
> 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.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)