Pattern selector

Most relevant patterns first. Most helpful ones displayed. Click here to show all.

  1. HashMap$ValueIterator.next() has thrown a ConcurrentModificationException
    Java Runtime
    10
    59
    15
  2. Trying to modify a HashMap directly while iterating over it
    Java Runtime
    89
    344
    50

Your stack trace compared to the selected pattern

Jump to solutionsExpand frames
java.util.ConcurrentModificationException
    at java.util.HashMap$HashIterator.nextEntry(Unknown Source)
    at java.util.HashMap$ValueIterator.next(Unknown Source)
    at org.ablogic.misc.FileMonitor$FileListenerTask.run(FileMonitor.java:187)
    at java.util.TimerThread.mainLoop(Unknown Source)
1 frame hidden

Solution

rahsan2 months ago

This kind of exception is thrown when you are trying to modify a HashMap directly (without using it's iterator) while iterating over it. To solve this problem, do one of the following:

  • Use a ConcurrentHashMap
  • Add - To add an entry while iterating, create a new HashMap, add all entries to this map. Once complete use HashMap.putAll() method to add all new entries to the original HashMap.
  • Remove - To remove an entry, use it's iterator's remove method. For more details check this answer

External results for this pattern (10)

  1. Owen Tranvia Google Groups1 month ago
  2. Unknown authorvia Google Groups1 month ago
    No message found for this stack trace.
    Show stack trace
  3. Ceki Gülcüvia QOS.ch JIRA1 month ago
    Unexpected initialization failure
    Show stack trace
  4. MJsayconvia GitHub1 month ago
    No message found for this stack trace.
    Show stack trace
  5. NmdOfficialvia GitHub2 months ago
    No message found for this stack trace.
    Show stack trace
  6. nicolas-raoulvia GitHub3 months ago
    No message found for this stack trace.
    Show stack trace
  7. nicolas-raoulvia GitHub3 months ago
    No message found for this stack trace.
    Show stack trace
  8. RubenMattanvia GitHub3 months ago
    No message found for this stack trace.
    Show stack trace