Skip to content

Commit

Permalink
fix SLF4J-563
Browse files Browse the repository at this point in the history
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
  • Loading branch information
ceki committed Sep 20, 2022
1 parent 7c1d86e commit 894b189
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void setContextMap(Map<String, String> contextMap) {

if (old == null) {
for (Map.Entry<String, String> mapEntry : contextMap.entrySet()) {
org.apache.log4j.MDC.put(mapEntry.getKey(), mapEntry);
org.apache.log4j.MDC.put(mapEntry.getKey(), mapEntry.getValue());
}
} else {
old.clear();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package org.slf4j.reload4j;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Test;
import org.slf4j.helpers.MDCAdapterTestBase;
import org.slf4j.spi.MDCAdapter;

import java.util.HashMap;
import java.util.Map;

import static org.junit.Assert.*;

public class Reload4jMDCAdapterTest extends MDCAdapterTestBase {

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

@Test
public void testSetContextMap() {
Map<String, String> map0 = new HashMap<>();
map0.put("key0", "val0");

mdc.setContextMap(map0);
Map map1 = mdc.getCopyOfContextMap();

assertEquals(map0, map1);
}


}

0 comments on commit 894b189

Please sign in to comment.