[ https://issues.apache.org/jira/browse/COLLECTIONS-768?focusedWorklogId=520502&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-520502 ]
ASF GitHub Bot logged work on COLLECTIONS-768: ---------------------------------------------- Author: ASF GitHub Bot Created on: 05/Dec/20 15:49 Start Date: 05/Dec/20 15:49 Worklog Time Spent: 10m Work Description: garydgregory commented on pull request #189: URL: https://github.com/apache/commons-collections/pull/189#issuecomment-739312957 @tongxin97 I do not think so. While it is not documented, the iteration order for a Flat3Map is in fact predictable when the size <= 3, and this is in fact checked, intentionally or not by the test. So this PR fixes the sanity check portion of test and looses the ordering test for the map we actually want to test. Therefore, the simple fix should be for the sanity check to use a `LinkedHashMap` instead of a `HashMap`, like this: ``` public void testEntrySet() { // Sanity check putAndRemove(new LinkedHashMap<>()); // Actual test putAndRemove(new Flat3Map<>()); } ``` This is presumably the intent of the test since the `putAndRemove` test method uses exactly three entries which matches exactly the intended size of useful Flat3Map instances. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 520502) Time Spent: 2h 20m (was: 2h 10m) > Flat3MapTest.tesetEntrySet() is flaky > ------------------------------------- > > Key: COLLECTIONS-768 > URL: https://issues.apache.org/jira/browse/COLLECTIONS-768 > Project: Commons Collections > Issue Type: Bug > Components: Map > Affects Versions: 4.4 > Reporter: XinT > Priority: Minor > Labels: easyfix, pull-request-available > Time Spent: 2h 20m > Remaining Estimate: 0h > > The testEntrySet() function > (org.apache.commons.collections4.map.Flat3MapTest#testEntrySet) is flaky > because it uses a flaky helper function putAndRemove(). The helper function > wrongly assumes that map iterators execute in insertion order, while in fact > it can be any order. > The current test asserts the last element iterated (and subsequently removed) > is the last element inserted. Therefore, the test passes when it so happens > that the last iterated element is the last inserted element, but fails > otherwise. > > The proposed fix is: https://github.com/apache/commons-collections/pull/189 > -- This message was sent by Atlassian Jira (v8.3.4#803005)