Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iterating of the map should not throw a ConcurrentModificationException #78

Merged
merged 1 commit into from
Sep 30, 2023
Merged

Iterating of the map should not throw a ConcurrentModificationException #78

merged 1 commit into from
Sep 30, 2023

Conversation

bratkartoffel
Copy link
Contributor

Create a copy of the entries (guarded by a readLock) and iterate over that copy.
This fixes #10 and maybe #30 (needs further testing though, couldn't reproduce that)

Create a copy of the underlying map and iterate over that, never throwing a ConcurrentModificationException. This comes with a small performance penalty though (copying the map content to new instance) but fixing the exception should have priority as this violates the contract of this class (threadsafe)

Create a copy of the entries (guarded by a readLock) and iterate over that copy.
This fixes #10
@bratkartoffel
Copy link
Contributor Author

@jhalterman this PR is open for some time now, have you had time to look into this?

@jhalterman jhalterman merged commit c5e0042 into jhalterman:master Sep 30, 2023
@jhalterman
Copy link
Owner

Thanks for this, and sorry for the huge delay. I don't love copying the map, but I agree with your point that thread safety is priority, so this is better than ConcurrentModificationException for now. I'll add a note about the copying behavior to the Javadoc and cut a new release.

@jhalterman
Copy link
Owner

This is released in 0.5.11.

bratkartoffel added a commit to bratkartoffel/expiringmap that referenced this pull request Dec 5, 2023
This is an addition to the fix implemented with jhalterman#78 which did not cover all cases.
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.

Concurrent Modification Exception
2 participants