This is an automated email from the ASF dual-hosted git repository.

mattsicker pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 734cb35e5f5500af8a6843023c7ff5b889d84dfa
Author: Matt Sicker <[email protected]>
AuthorDate: Mon Jan 1 18:07:12 2024 -0600

    Simplify ThreadContextInitializer
    
    Signed-off-by: Matt Sicker <[email protected]>
---
 .../logging/log4j/test/junit/ThreadContextInitializer.java  | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git 
a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ThreadContextInitializer.java
 
b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ThreadContextInitializer.java
index 8afceef737..309fb2fcb4 100644
--- 
a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ThreadContextInitializer.java
+++ 
b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ThreadContextInitializer.java
@@ -17,7 +17,6 @@
 package org.apache.logging.log4j.test.junit;
 
 import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.test.ThreadContextUtilityClass;
 import org.junit.jupiter.api.extension.BeforeAllCallback;
 import org.junit.jupiter.api.extension.BeforeEachCallback;
 import org.junit.jupiter.api.extension.ExtensionContext;
@@ -41,18 +40,10 @@ class ThreadContextInitializer implements 
BeforeAllCallback, BeforeEachCallback
     }
 
     private void resetThreadContext(final ExtensionContext context) {
-        ThreadContextUtilityClass.reset();
+        ThreadContext.init();
         // We use `CloseableResource` instead of `afterAll` to reset the
         // ThreadContextFactory
         // *after* the `@SetSystemProperty` extension has restored the 
properties
-        ExtensionContextAnchor.setAttribute(
-                ThreadContext.class,
-                new CloseableResource() {
-                    @Override
-                    public void close() throws Throwable {
-                        ThreadContextUtilityClass.reset();
-                    }
-                },
-                context);
+        ExtensionContextAnchor.setAttribute(ThreadContext.class, 
(CloseableResource) ThreadContext::init, context);
     }
 }

Reply via email to