[logback-dev] [JIRA] Resolved: (LBCLASSIC-289) ConcurrentModificationException when using MDC

Ceki Gulcu (JIRA) noreply-jira at qos.ch
Tue Sep 20 21:56:16 CEST 2011

     [ http://jira.qos.ch/browse/LBCLASSIC-289?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ceki Gulcu resolved LBCLASSIC-289.

    Fix Version/s: 0.9.30
       Resolution: Fixed

Fixed in [1] . LogbackMDCAdapter now synchronizes over its thread local map. This prevents ConcurrentModificationException from occurring while a child thread copies the map from the parent. There should be very little contention due to the synchronization because unrelated threads use different maps and parent/child threads will use different maps after the first write operation performed by the child thread. 

[1] http://github.com/ceki/logback/commit/7a2e02bca24

> ConcurrentModificationException when using MDC
> ----------------------------------------------
>                 Key: LBCLASSIC-289
>                 URL: http://jira.qos.ch/browse/LBCLASSIC-289
>             Project: logback-classic
>          Issue Type: Bug
>          Components: appender
>    Affects Versions: 0.9.29
>         Environment: Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02-383, mixed mode)
> Darwin aden 11.1.0 Darwin Kernel Version 11.1.0: Tue Jul 26 16:07:11 PDT 2011; root:xnu-1699.22.81~1/RELEASE_X86_64 x86_64
>            Reporter: Josh Oddman
>            Assignee: Ceki Gulcu
>             Fix For: 0.9.30
> In some rare cases in multithreaded environment MDC.put throws ConcurrentModificationException.
> java.util.ConcurrentModificationException: null 
>         at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793) ~[na:1.6.0_26] 
>         at java.util.HashMap$EntryIterator.next(HashMap.java:834) ~[na:1.6.0_26] 
>         at java.util.HashMap$EntryIterator.next(HashMap.java:832) ~[na:1.6.0_26] 
>         at java.util.HashMap.putAll(HashMap.java:523) ~[na:1.6.0_26] 
>         at ch.qos.logback.classic.util.LogbackMDCAdapter.duplicateAndInsertNewMap(LogbackMDCAdapter.java:69) 
> ~[logback-classic-0.9.29.jar:na] 
>         at ch.qos.logback.classic.util.LogbackMDCAdapter.put(LogbackMDCAdapter.java:95) 
> ~[logback-classic-0.9.29.jar:na] 
>         at org.slf4j.MDC.put(MDC.java:112) ~[slf4j-api-1.6.1.jar:1.6.1] 

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the logback-dev mailing list