Skip to content

Commit

Permalink
Optimization: use Collections.emptyMap() in LoggingEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
panchenko committed Apr 13, 2015
1 parent 985257f commit 3d5cf2e
Showing 1 changed file with 2 additions and 5 deletions.
Expand Up @@ -16,12 +16,10 @@
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import org.slf4j.MDC;
import org.slf4j.Marker;
import org.slf4j.helpers.FormattingTuple;
import org.slf4j.helpers.MessageFormatter;

import ch.qos.logback.classic.Level;
Expand Down Expand Up @@ -93,7 +91,6 @@ public class LoggingEvent implements ILoggingEvent {
private Marker marker;

private Map<String, String> mdcPropertyMap;
private static final Map<String, String> CACHED_NULL_MAP = Collections.unmodifiableMap(new HashMap<String, String>());

/**
* The number of milliseconds elapsed from 1/1/1970 until logging event was
Expand Down Expand Up @@ -315,9 +312,9 @@ public Map<String, String> getMDCPropertyMap() {
else
mdcPropertyMap = mdc.getCopyOfContextMap();
}
// mdcPropertyMap still null, use CACHED_NULL_MAP
// mdcPropertyMap still null, use emptyMap()
if (mdcPropertyMap == null)
mdcPropertyMap = CACHED_NULL_MAP;
mdcPropertyMap = Collections.emptyMap();

return mdcPropertyMap;
}
Expand Down

0 comments on commit 3d5cf2e

Please sign in to comment.