ConcurrentModificationException :: Iterating through map while expirator is running
See original GitHub issueHello,
For my use case of expiring map I see a ConcurrentModification exception when using an Expirator with policy CREATED. The issue occurs when an iteration is made on the map and an expirator is running:
java.util.ConcurrentModificationException
at java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:711)
at java.util.LinkedHashMap$LinkedEntryIterator.next(LinkedHashMap.java:744)
at java.util.LinkedHashMap$LinkedEntryIterator.next(LinkedHashMap.java:742)
at net.jodah.expiringmap.ExpiringMap$EntryLinkedHashMap$AbstractHashIterator.getNext(ExpiringMap.java:364)
at net.jodah.expiringmap.ExpiringMap$EntryLinkedHashMap$EntryIterator.getNext(ExpiringMap.java:385)
at net.jodah.expiringmap.ExpiringMap$EntryLinkedHashMap$EntryIterator.next(ExpiringMap.java:387)
at net.jodah.expiringmap.ExpiringMap$EntryLinkedHashMap$EntryIterator.next(ExpiringMap.java:385)
at net.jodah.expiringmap.functional.ConcurrencyTestWithExpirator.deleteWithEntrySetIterator(ConcurrencyTestWithExpirator.java:40)`
This happens with both EntrySet iterator, or values/keyset iterators.
Note: I read about issue https://github.com/jhalterman/expiringmap/issues/10 that is why I tried with EntrySet too.
Thank you!
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:12 (1 by maintainers)
Top Results From Across the Web
ConcurrentModificationException while iterating Map [duplicate]
now I am working with an android game and the code above is running in multithreaded way. Now I am having an exception...
Read more >java.util.ConcurrentModificationException - DigitalOcean
Java Collection classes are fail-fast, which means if the Collection will be changed while some thread is traversing over it using iterator, ...
Read more >expiringmap - Bountysource
ConcurrentModificationException :: Iterating through map while expirator is ... occurs when an iteration is made on the map and an expirator is running:...
Read more >[Solved]-Accessing map gives java.util ...
ConcurrentModificationException although map is updated using ... could also be caused by modifying the map while iterating over it from a single thread, ......
Read more >Map - Hazelcast Documentation
When you run this code, a cluster member is created with a map whose entries ... the expiration, and hence the eviction based...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
👍
What do you mean by
inconsistency of getIfPresent() under heavily multi-threaded
? One would expect entries to expire with some threads seeing it and some not. In both libraries the use ofgetIfPresent()
is disfavored compared to a computingget
.