@@ -35,7 +35,6 @@ public class LogbackMDCAdapterTest {
3535
3636 private final LogbackMDCAdapter mdcAdapter = new LogbackMDCAdapter ();
3737
38-
3938 /**
4039 * Test that CopyOnInheritThreadLocal does not barf when the
4140 * MDC hashmap is null
@@ -67,12 +66,12 @@ public void removeInexistentKey() {
6766 @ Test
6867 public void sequenceWithGet () {
6968 mdcAdapter .put ("k0" , "v0" );
70- Map <String , String > map0 = mdcAdapter .copyOnInheritThreadLocal .get ();
69+ Map <String , String > map0 = mdcAdapter .copyOnThreadLocal .get ();
7170 mdcAdapter .get ("k0" );
7271 mdcAdapter .put ("k1" , "v1" ); // no map copy required
7372
7473 // verify that map0 is the same instance and that value was updated
75- assertSame (map0 , mdcAdapter .copyOnInheritThreadLocal .get ());
74+ assertSame (map0 , mdcAdapter .copyOnThreadLocal .get ());
7675 }
7776
7877
@@ -88,25 +87,25 @@ public void sequenceWithGetPropertyMap() {
8887 @ Test
8988 public void sequenceWithCopyContextMap () {
9089 mdcAdapter .put ("k0" , "v0" );
91- Map <String , String > map0 = mdcAdapter .copyOnInheritThreadLocal .get ();
90+ Map <String , String > map0 = mdcAdapter .copyOnThreadLocal .get ();
9291 mdcAdapter .getCopyOfContextMap ();
9392 mdcAdapter .put ("k1" , "v1" ); // no map copy required
9493
9594 // verify that map0 is the same instance and that value was updated
96- assertSame (map0 , mdcAdapter .copyOnInheritThreadLocal .get ());
95+ assertSame (map0 , mdcAdapter .copyOnThreadLocal .get ());
9796 }
9897
9998
10099 // =================================================
101100
102101 /**
103- * Test that LogbackMDCAdapter copies its hashmap when a child
102+ * Test that LogbackMDCAdapter does not copy its hashmap when a child
104103 * thread inherits it.
105104 *
106105 * @throws InterruptedException
107106 */
108107 @ Test
109- public void copyOnInheritenceTest () throws InterruptedException {
108+ public void noCopyOnInheritenceTest () throws InterruptedException {
110109 CountDownLatch countDownLatch = new CountDownLatch (1 );
111110 String firstKey = "x" + diff ;
112111 String secondKey = "o" + diff ;
@@ -129,7 +128,6 @@ public void copyOnInheritenceTest() throws InterruptedException {
129128 assertEquals (parentHMWitness , parentHM );
130129
131130 HashMap <String , String > childHMWitness = new HashMap <String , String >();
132- childHMWitness .put (firstKey , firstKey + A_SUFFIX );
133131 childHMWitness .put (secondKey , secondKey + A_SUFFIX );
134132 assertEquals (childHMWitness , childThread .childHM );
135133
@@ -195,8 +193,8 @@ public void run() {
195193
196194
197195 Map <String , String > getMapFromMDCAdapter (LogbackMDCAdapter lma ) {
198- InheritableThreadLocal <Map <String , String >> copyOnInheritThreadLocal = lma .copyOnInheritThreadLocal ;
199- return copyOnInheritThreadLocal .get ();
196+ ThreadLocal <Map <String , String >> copyOnThreadLocal = lma .copyOnThreadLocal ;
197+ return copyOnThreadLocal .get ();
200198 }
201199
202200 // ========================== various thread classes
@@ -247,10 +245,11 @@ class ChildThread extends Thread {
247245 @ Override
248246 public void run () {
249247 logbackMDCAdapter .put (secondKey , secondKey + A_SUFFIX );
250- assertNotNull (logbackMDCAdapter .get (firstKey ));
251- assertEquals (firstKey + A_SUFFIX , logbackMDCAdapter .get (firstKey ));
248+ assertNull (logbackMDCAdapter .get (firstKey ));
252249 if (countDownLatch != null ) countDownLatch .countDown ();
250+ assertNotNull (logbackMDCAdapter .get (secondKey ));
253251 assertEquals (secondKey + A_SUFFIX , logbackMDCAdapter .get (secondKey ));
252+
254253 successful = true ;
255254 childHM = getMapFromMDCAdapter (logbackMDCAdapter );
256255 }
0 commit comments