Closed bratkartoffel closed 9 months ago
@jhalterman this PR is open for some time now, have you had time to look into this?
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.
This is released in 0.5.11.
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)