Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix concurrent map flakiness#472

Open
shunfan-shao wants to merge 5 commits intoapache:masterfrom
shunfan-shao:fix-concurrent-map-flakiness
Open

Fix concurrent map flakiness#472
shunfan-shao wants to merge 5 commits intoapache:masterfrom
shunfan-shao:fix-concurrent-map-flakiness

Conversation

Copy link

shunfan-shao commented Nov 18, 2021

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant