java.util.ConcurrentModificationException

QOS.ch JIRA | Alex | 1 year ago
  1. 0

    ConcurrentModificationException can be thrown whilst status event is fired out into registered StatusListeners but one of the listener is removed at the same time from a different thread. An example of stack trace for the issue is provided below {noformat} 11:31:11,081 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[logfile] - Appender [logfile] failed to append. java.util.ConcurrentModificationException at java.util.ConcurrentModificationException at at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:859) at at java.util.ArrayList$Itr.next(ArrayList.java:831) at at ch.qos.logback.core.BasicStatusManager.fireStatusAddEvent(BasicStatusManager.java:86) at at ch.qos.logback.core.BasicStatusManager.add(BasicStatusManager.java:59) at at ch.qos.logback.core.recovery.ResilientOutputStreamBase.addStatus(ResilientOutputStreamBase.java:157) at at ch.qos.logback.core.recovery.ResilientOutputStreamBase.addStatusIfCountNotOverLimit(ResilientOutputStreamBase.java:138) at at ch.qos.logback.core.recovery.ResilientOutputStreamBase.postIOFailure(ResilientOutputStreamBase.java:101) at at ch.qos.logback.core.recovery.ResilientOutputStreamBase.flush(ResilientOutputStreamBase.java:82) at at ch.qos.logback.core.encoder.LayoutWrappingEncoder.doEncode(LayoutWrappingEncoder.java:137) at at ch.qos.logback.core.OutputStreamAppender.writeOut(OutputStreamAppender.java:194) at at ch.qos.logback.core.FileAppender.writeOut(FileAppender.java:209) at at ch.qos.logback.core.OutputStreamAppender.subAppend(OutputStreamAppender.java:219) at at ch.qos.logback.core.rolling.RollingFileAppender.subAppend(RollingFileAppender.java:182) at at ch.qos.logback.core.OutputStreamAppender.append(OutputStreamAppender.java:103) at at ch.qos.logback.core.UnsynchronizedAppenderBase.doAppend(UnsynchronizedAppenderBase.java:88) at at ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:48) at at ch.qos.logback.classic.Logger.appendLoopOnAppenders(Logger.java:273) at at ch.qos.logback.classic.Logger.callAppenders(Logger.java:260) at at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:442) at at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:396) at at ch.qos.logback.classic.Logger.error(Logger.java:559) {noformat} The easiest way to reproduce it would be to implement status listener unregistering itself from addStatusEvent: {code} class MyListener implements StatusListener { private StatusManager _statusManager; public MyListener(StatusManager statusManager) { _statusManager = statusManager; } @Override public void addStatusEvent(Status status) { _statusManager.remove(this); } } {code} The issue affects the application creating and removing Appenders dynamically and registering/unregistering StatusListeners on appender creation and removing accordingly.

    QOS.ch JIRA | 1 year ago | Alex
    java.util.ConcurrentModificationException
  2. 0

    ConcurrentModificationException can be thrown whilst status event is fired out into registered StatusListeners but one of the listener is removed at the same time from a different thread. An example of stack trace for the issue is provided below {noformat} 11:31:11,081 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[logfile] - Appender [logfile] failed to append. java.util.ConcurrentModificationException at java.util.ConcurrentModificationException at at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:859) at at java.util.ArrayList$Itr.next(ArrayList.java:831) at at ch.qos.logback.core.BasicStatusManager.fireStatusAddEvent(BasicStatusManager.java:86) at at ch.qos.logback.core.BasicStatusManager.add(BasicStatusManager.java:59) at at ch.qos.logback.core.recovery.ResilientOutputStreamBase.addStatus(ResilientOutputStreamBase.java:157) at at ch.qos.logback.core.recovery.ResilientOutputStreamBase.addStatusIfCountNotOverLimit(ResilientOutputStreamBase.java:138) at at ch.qos.logback.core.recovery.ResilientOutputStreamBase.postIOFailure(ResilientOutputStreamBase.java:101) at at ch.qos.logback.core.recovery.ResilientOutputStreamBase.flush(ResilientOutputStreamBase.java:82) at at ch.qos.logback.core.encoder.LayoutWrappingEncoder.doEncode(LayoutWrappingEncoder.java:137) at at ch.qos.logback.core.OutputStreamAppender.writeOut(OutputStreamAppender.java:194) at at ch.qos.logback.core.FileAppender.writeOut(FileAppender.java:209) at at ch.qos.logback.core.OutputStreamAppender.subAppend(OutputStreamAppender.java:219) at at ch.qos.logback.core.rolling.RollingFileAppender.subAppend(RollingFileAppender.java:182) at at ch.qos.logback.core.OutputStreamAppender.append(OutputStreamAppender.java:103) at at ch.qos.logback.core.UnsynchronizedAppenderBase.doAppend(UnsynchronizedAppenderBase.java:88) at at ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:48) at at ch.qos.logback.classic.Logger.appendLoopOnAppenders(Logger.java:273) at at ch.qos.logback.classic.Logger.callAppenders(Logger.java:260) at at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:442) at at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:396) at at ch.qos.logback.classic.Logger.error(Logger.java:559) {noformat} The easiest way to reproduce it would be to implement status listener unregistering itself from addStatusEvent: {code} class MyListener implements StatusListener { private StatusManager _statusManager; public MyListener(StatusManager statusManager) { _statusManager = statusManager; } @Override public void addStatusEvent(Status status) { _statusManager.remove(this); } } {code} The issue affects the application creating and removing Appenders dynamically and registering/unregistering StatusListeners on appender creation and removing accordingly.

    QOS.ch JIRA | 1 year ago | Alex
    java.util.ConcurrentModificationException
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    ConcurrentModificationException when running tests concurrently

    GitHub | 2 years ago | thiagoh
    java.util.ConcurrentModificationException

  1. serious2monkeys 2 times, last 1 month ago
  2. eti22 4 times, last 2 months ago
  3. Tahir 1 times, last 4 months ago
  4. Shadd518 2 times, last 4 months ago
  5. haerick 1 times, last 6 months ago
5 more registered users
23 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.util.ConcurrentModificationException

    No message provided

    at java.util.ArrayList$Itr.checkForComodification()
  2. Java RT
    ArrayList$Itr.next
    1. java.util.ArrayList$Itr.checkForComodification(ArrayList.java:859)
    2. java.util.ArrayList$Itr.next(ArrayList.java:831)
    2 frames
  3. Logback Core Module
    AppenderAttachableImpl.appendLoopOnAppenders
    1. ch.qos.logback.core.BasicStatusManager.fireStatusAddEvent(BasicStatusManager.java:86)
    2. ch.qos.logback.core.BasicStatusManager.add(BasicStatusManager.java:59)
    3. ch.qos.logback.core.recovery.ResilientOutputStreamBase.addStatus(ResilientOutputStreamBase.java:157)
    4. ch.qos.logback.core.recovery.ResilientOutputStreamBase.addStatusIfCountNotOverLimit(ResilientOutputStreamBase.java:138)
    5. ch.qos.logback.core.recovery.ResilientOutputStreamBase.postIOFailure(ResilientOutputStreamBase.java:101)
    6. ch.qos.logback.core.recovery.ResilientOutputStreamBase.flush(ResilientOutputStreamBase.java:82)
    7. ch.qos.logback.core.encoder.LayoutWrappingEncoder.doEncode(LayoutWrappingEncoder.java:137)
    8. ch.qos.logback.core.OutputStreamAppender.writeOut(OutputStreamAppender.java:194)
    9. ch.qos.logback.core.FileAppender.writeOut(FileAppender.java:209)
    10. ch.qos.logback.core.OutputStreamAppender.subAppend(OutputStreamAppender.java:219)
    11. ch.qos.logback.core.rolling.RollingFileAppender.subAppend(RollingFileAppender.java:182)
    12. ch.qos.logback.core.OutputStreamAppender.append(OutputStreamAppender.java:103)
    13. ch.qos.logback.core.UnsynchronizedAppenderBase.doAppend(UnsynchronizedAppenderBase.java:88)
    14. ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:48)
    14 frames
  4. Logback Classic Module
    Logger.error
    1. ch.qos.logback.classic.Logger.appendLoopOnAppenders(Logger.java:273)
    2. ch.qos.logback.classic.Logger.callAppenders(Logger.java:260)
    3. ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:442)
    4. ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:396)
    5. ch.qos.logback.classic.Logger.error(Logger.java:559)
    5 frames