From d96a7f30478e5989f9bd6ff8a665432ef6475f8e Mon Sep 17 00:00:00 2001 From: Carter Kozak Date: Tue, 12 Jun 2018 12:08:10 -0400 Subject: [PATCH] Apply ThreadContextRule to Log4j1XmlLayoutTest NDC value is leaking into the test intermittently causing a comparison to fail. --- .../java/org/apache/log4j/layout/Log4j1XmlLayoutTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/layout/Log4j1XmlLayoutTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/layout/Log4j1XmlLayoutTest.java index 395cf3b3e98..28579fef0a8 100644 --- a/log4j-1.2-api/src/test/java/org/apache/log4j/layout/Log4j1XmlLayoutTest.java +++ b/log4j-1.2-api/src/test/java/org/apache/log4j/layout/Log4j1XmlLayoutTest.java @@ -21,12 +21,17 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.core.impl.ContextDataFactory; import org.apache.logging.log4j.core.impl.Log4jLogEvent; +import org.apache.logging.log4j.junit.ThreadContextRule; import org.apache.logging.log4j.message.SimpleMessage; import org.apache.logging.log4j.util.StringMap; +import org.junit.Rule; import org.junit.Test; public class Log4j1XmlLayoutTest { + @Rule + public ThreadContextRule threadContextRule = new ThreadContextRule(); + @Test public void testWithoutThrown() { final Log4j1XmlLayout layout = Log4j1XmlLayout.createLayout(false, true);