Issue Type: Improvement Improvement
Affects Versions: 1.0.13
Assignee: Logback dev list
Created: 03/Feb/14 11:22 AM
Description:

When using MDC and thread pools, code usually follows this pattern:

final Map context = MDC.getCopyOfContextMap();
executor.submit(new Runnable() {
	@Override
	public void run() {
		MDC.setContextMap(context);
	}

But if no MDC variables are set, getCopyOfContextMap() returns null and setContextMap then blows up. LogbackMDCAdapter.setContextMap uses Map.putAll which doesn't accept null. Therefore, one has to wrap the call to setContextMap in an annoying null check.

I suggest that setContextMap should handle a null argument gracefully by returning early. Alternatively, return Collections.emptyMap() or similar from getCopyOfContextMap.

Project: logback
Priority: Minor Minor
Reporter: Thomas Kappler
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira