Skip to content

Conversation

shunfan-shao
Copy link

Description

Test org.apache.cayenne.util.WeakValueMapTest.testConcurrentModification will fail under NonDex which detects flakiness under non-deterministic environment.

To reproduce:

mvn edu.illinois:nondex-maven-plugin:1.1.2:nondex \
    -pl cayenne-server \
    -Dtest=org.apache.cayenne.util.WeakValueMapTest#testConcurrentModification

Issue

The test code follows the logic below:

Map<String, Integer> map = new WeakValueMap<>(3);
for(Map.Entry<String, Integer> entry : map.entrySet()) {
    if("key_2".equals(entry.getKey())) 
        map.remove("key_2");
}

While WeakValueMap uses HashMap internally, it is not guaranteed for map.entrySet to iterate over the entries under some orders.

The code is expected to thrown ConcurrentModificationException during execution. Under some edge cases, eg: key_2 is traversed and removed last, the test will fail to throw and cause an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant