Skip to content

Commit 894b189

Browse files
committed
fix SLF4J-563
Signed-off-by: Ceki Gulcu <[email protected]>
1 parent 7c1d86e commit 894b189

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

slf4j-reload4j/src/main/java/org/slf4j/reload4j/Reload4jMDCAdapter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void setContextMap(Map<String, String> contextMap) {
9696

9797
if (old == null) {
9898
for (Map.Entry<String, String> mapEntry : contextMap.entrySet()) {
99-
org.apache.log4j.MDC.put(mapEntry.getKey(), mapEntry);
99+
org.apache.log4j.MDC.put(mapEntry.getKey(), mapEntry.getValue());
100100
}
101101
} else {
102102
old.clear();

slf4j-reload4j/src/test/java/org/slf4j/reload4j/Reload4jMDCAdapterTest.java

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package org.slf4j.reload4j;
22

3-
import static org.junit.Assert.assertFalse;
4-
import static org.junit.Assert.assertTrue;
5-
63
import org.junit.Test;
74
import org.slf4j.helpers.MDCAdapterTestBase;
85
import org.slf4j.spi.MDCAdapter;
96

7+
import java.util.HashMap;
8+
import java.util.Map;
9+
10+
import static org.junit.Assert.*;
11+
1012
public class Reload4jMDCAdapterTest extends MDCAdapterTestBase {
1113

1214
protected MDCAdapter instantiateMDC() {
@@ -22,6 +24,16 @@ public void testClearingMDC() {
2224
assertTrue(mdc.getCopyOfContextMap().isEmpty());
2325
}
2426

27+
@Test
28+
public void testSetContextMap() {
29+
Map<String, String> map0 = new HashMap<>();
30+
map0.put("key0", "val0");
31+
32+
mdc.setContextMap(map0);
33+
Map map1 = mdc.getCopyOfContextMap();
34+
35+
assertEquals(map0, map1);
36+
}
2537

2638

2739
}

0 commit comments

Comments
 (0)