[slf4j-user] BasicMDCAdapter thread issue

Raimo Järvi raimo.jarvi at gmail.com
Wed Oct 20 13:57:57 CEST 2010


Hi,

I've had some thread issues with Apache FTP server
(http://mina.apache.org/ftpserver/) and it looks like the problems
might be connected to SLF4J. I'm using the jdk14 binding in SLF4J
version 1.5.11, but version 1.6.1 seems to have the same issue.

Sometimes threads in the FTP server go to an infinite loop and the
server becomes unresponsive. When I do a thread dump, I see something
like this (FTP server classes removed from the stack trace):

java.lang.Thread.State: RUNNABLE
	at java.util.HashMap.removeEntryForKey(Unknown Source)
	at java.util.HashMap.remove(Unknown Source)
	at org.slf4j.helpers.BasicMDCAdapter.remove(BasicMDCAdapter.java:91)
	at org.slf4j.MDC.remove(MDC.java:150)

java.lang.Thread.State: RUNNABLE
	at java.util.HashMap.put(Unknown Source)
	at org.slf4j.helpers.BasicMDCAdapter.put(BasicMDCAdapter.java:70)
	at org.slf4j.MDC.put(MDC.java:109)

I've looked at BasicMDCAdapter code and it looks like the same HashMap
may be returned for multiple threads. Is BasicMDCAdapter not thread
safe or am I missing something?

Regards,
Raimo


More information about the slf4j-user mailing list