question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ConcurrentModificationException :: Iterating through map while expirator is running

See original GitHub issue

Hello,

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:open
  • Created 7 years ago
  • Reactions:6
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
charlesviencommented, Jul 9, 2016

👍

0reactions
ben-manescommented, Nov 14, 2019

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 of getIfPresent() is disfavored compared to a computing get.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found