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

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


The following commit(s) were added to refs/heads/main by this push:
     new c973563c37 Remove the QueuedScopedContextProvider as that is now the 
default
c973563c37 is described below

commit c973563c37ee1c89191bd4b1c9f0d28911ab4117
Author: Ralph Goers <[email protected]>
AuthorDate: Fri May 24 11:49:24 2024 -0700

    Remove the QueuedScopedContextProvider as that is now the default
---
 .../logging/log4j/core/impl/Log4jProvider.java     | 15 -----
 .../impl/internal/QueuedScopedContextProvider.java | 70 ----------------------
 2 files changed, 85 deletions(-)

diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jProvider.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jProvider.java
index be342cc3f2..ae80ba2d3c 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jProvider.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jProvider.java
@@ -18,9 +18,7 @@ package org.apache.logging.log4j.core.impl;
 
 import aQute.bnd.annotation.Resolution;
 import aQute.bnd.annotation.spi.ServiceProvider;
-import java.util.ServiceLoader;
 import 
org.apache.logging.log4j.core.impl.CoreProperties.ThreadContextProperties;
-import org.apache.logging.log4j.core.impl.internal.QueuedScopedContextProvider;
 import org.apache.logging.log4j.kit.env.PropertyEnvironment;
 import org.apache.logging.log4j.plugins.Inject;
 import org.apache.logging.log4j.plugins.di.ConfigurableInstanceFactory;
@@ -28,11 +26,8 @@ import org.apache.logging.log4j.plugins.di.DI;
 import org.apache.logging.log4j.plugins.di.Key;
 import org.apache.logging.log4j.spi.LoggerContextFactory;
 import org.apache.logging.log4j.spi.Provider;
-import org.apache.logging.log4j.spi.ScopedContextProvider;
 import org.apache.logging.log4j.spi.ThreadContextMap;
-import org.apache.logging.log4j.status.StatusLogger;
 import org.apache.logging.log4j.util.Constants;
-import org.apache.logging.log4j.util.ServiceLoaderUtil;
 
 /**
  * Binding for the Log4j API.
@@ -80,14 +75,4 @@ public class Log4jProvider extends Provider {
     public ThreadContextMap getThreadContextMapInstance() {
         return 
instanceFactory.getInstance(Key.forClass(ThreadContextMap.class));
     }
-
-    @Override
-    public ScopedContextProvider getScopedContextProvider() {
-        return ServiceLoaderUtil.safeStream(
-                        ScopedContextProvider.class,
-                        ServiceLoader.load(ScopedContextProvider.class),
-                        StatusLogger.getLogger())
-                .findFirst()
-                .orElse(QueuedScopedContextProvider.INSTANCE);
-    }
 }
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/internal/QueuedScopedContextProvider.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/internal/QueuedScopedContextProvider.java
deleted file mode 100644
index 626b9c0255..0000000000
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/internal/QueuedScopedContextProvider.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.core.impl.internal;
-
-import java.util.ArrayDeque;
-import java.util.Deque;
-import java.util.Optional;
-import org.apache.logging.log4j.spi.AbstractScopedContextProvider;
-import org.apache.logging.log4j.spi.ScopedContextProvider;
-
-public class QueuedScopedContextProvider extends AbstractScopedContextProvider 
{
-
-    public static final ScopedContextProvider INSTANCE = new 
QueuedScopedContextProvider();
-
-    private final ThreadLocal<Deque<Instance>> scopedContext = new 
ThreadLocal<>();
-
-    /**
-     * Returns an immutable Map containing all the key/value pairs as Object 
objects.
-     * @return An immutable copy of the Map at the current scope.
-     */
-    @Override
-    protected Optional<Instance> getContext() {
-        final Deque<Instance> stack = scopedContext.get();
-        return stack != null ? Optional.of(stack.getFirst()) : 
Optional.empty();
-    }
-
-    /**
-     * Add the ScopeContext.
-     * @param context The ScopeContext.
-     */
-    @Override
-    protected void addScopedContext(final MapInstance context) {
-        Deque<Instance> stack = scopedContext.get();
-        if (stack == null) {
-            stack = new ArrayDeque<>();
-            scopedContext.set(stack);
-        }
-        stack.addFirst(context);
-    }
-
-    /**
-     * Remove the top ScopeContext.
-     */
-    @Override
-    protected void removeScopedContext() {
-        final Deque<Instance> stack = scopedContext.get();
-        if (stack != null) {
-            if (!stack.isEmpty()) {
-                stack.removeFirst();
-            }
-            if (stack.isEmpty()) {
-                scopedContext.remove();
-            }
-        }
-    }
-}

Reply via email to