Skip to content

Commit

Permalink
LOGBACK-1337 LogbackMDCAdapter should store mdc in LinkedHashMap to p…
Browse files Browse the repository at this point in the history
…redict order of MDC in %X
  • Loading branch information
motlin committed Oct 8, 2024
1 parent 77e95e0 commit fb2ce09
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

Expand Down Expand Up @@ -71,7 +71,7 @@ public void put(String key, String val) throws IllegalArgumentException {
}
Map<String, String> current = readWriteThreadLocalMap.get();
if (current == null) {
current = new HashMap<String, String>();
current = new LinkedHashMap<>();
readWriteThreadLocalMap.set(current);
}

Expand Down Expand Up @@ -138,7 +138,7 @@ public Map<String, String> getPropertyMap() {
if (readOnlyMap == null) {
Map<String, String> current = readWriteThreadLocalMap.get();
if (current != null) {
final Map<String, String> tempMap = new HashMap<String, String>(current);
final Map<String, String> tempMap = new LinkedHashMap<>(current);
readOnlyMap = Collections.unmodifiableMap(tempMap);
readOnlyThreadLocalMap.set(readOnlyMap);
}
Expand All @@ -155,7 +155,7 @@ public Map getCopyOfContextMap() {
if (readOnlyMap == null) {
return null;
} else {
return new HashMap<String, String>(readOnlyMap);
return new LinkedHashMap(readOnlyMap);
}
}

Expand All @@ -176,7 +176,7 @@ public Set<String> getKeys() {
@SuppressWarnings("unchecked")
public void setContextMap(Map contextMap) {
if (contextMap != null) {
readWriteThreadLocalMap.set(new HashMap<String, String>(contextMap));
readWriteThreadLocalMap.set(new LinkedHashMap<>(contextMap));
} else {
readWriteThreadLocalMap.set(null);
}
Expand Down

0 comments on commit fb2ce09

Please sign in to comment.