logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1484363 - in /logging/log4j/log4j2/trunk: api/src/main/java/org/apache/logging/log4j/simple/ api/src/main/java/org/apache/logging/log4j/spi/ api/src/test/java/org/apache/logging/log4j/ core/src/main/java/org/apache/logging/log4j/core/ core...
Date Sun, 19 May 2013 22:29:14 GMT
Author: rgoers
Date: Sun May 19 22:29:14 2013
New Revision: 1484363

URL: http://svn.apache.org/r1484363
Log:
LOG4J2-223 - Remove LoggerContext when LoggerContext is stopped

Modified:
    logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContextFactory.java
    logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/spi/LoggerContextFactory.java
    logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/TestLoggerContextFactory.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelector.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/selector/BasicContextSelector.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/selector/ContextSelector.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/selector/JNDIContextSelector.java
    logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContextFactory.java
    logging/log4j/log4j2/trunk/src/changes/changes.xml

Modified: logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContextFactory.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContextFactory.java?rev=1484363&r1=1484362&r2=1484363&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContextFactory.java
(original)
+++ logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContextFactory.java
Sun May 19 22:29:14 2013
@@ -38,4 +38,8 @@ public class SimpleLoggerContextFactory 
                                     URI configLocation) {
         return context;
     }
+
+    @Override
+    public void removeContext(LoggerContext context) {
+    }
 }

Modified: logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/spi/LoggerContextFactory.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/spi/LoggerContextFactory.java?rev=1484363&r1=1484362&r2=1484363&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/spi/LoggerContextFactory.java
(original)
+++ logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/spi/LoggerContextFactory.java
Sun May 19 22:29:14 2013
@@ -45,4 +45,10 @@ public interface LoggerContextFactory {
      * @return The LoggerContext.
      */
     LoggerContext getContext(String fqcn, ClassLoader loader, boolean currentContext, URI
configLocation);
+
+    /**
+     * Removes knowledge of a LoggerContext.
+     * @param The context to remove.
+     */
+    void removeContext(LoggerContext context);
 }

Modified: logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/TestLoggerContextFactory.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/TestLoggerContextFactory.java?rev=1484363&r1=1484362&r2=1484363&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/TestLoggerContextFactory.java
(original)
+++ logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/TestLoggerContextFactory.java
Sun May 19 22:29:14 2013
@@ -38,4 +38,8 @@ public class TestLoggerContextFactory im
                                     URI configLocation) {
         return context;
     }
+
+    @Override
+    public void removeContext(LoggerContext context) {
+    }
 }

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java?rev=1484363&r1=1484362&r2=1484363&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
Sun May 19 22:29:14 2013
@@ -28,6 +28,7 @@ import java.util.concurrent.CopyOnWriteA
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
+import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.ConfigurationFactory;
 import org.apache.logging.log4j.core.config.ConfigurationListener;
@@ -202,6 +203,7 @@ public class LoggerContext implements or
             updateLoggers();
             prev.stop();
             externalContext = null;
+            LogManager.getFactory().removeContext(this);
             status = Status.STOPPED;
         } finally {
             configLock.unlock();

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelector.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelector.java?rev=1484363&r1=1484362&r2=1484363&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelector.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelector.java
Sun May 19 22:29:14 2013
@@ -29,12 +29,10 @@ import org.apache.logging.log4j.core.sel
  */
 public class AsyncLoggerContextSelector implements ContextSelector {
 
-    private static final AsyncLoggerContext CONTEXT = new AsyncLoggerContext(
-            "AsyncLoggerContext");
+    private static final AsyncLoggerContext CONTEXT = new AsyncLoggerContext("AsyncLoggerContext");
 
     @Override
-    public LoggerContext getContext(String fqcn, ClassLoader loader,
-            boolean currentContext) {
+    public LoggerContext getContext(String fqcn, ClassLoader loader, boolean currentContext)
{
         return CONTEXT;
     }
 
@@ -46,9 +44,12 @@ public class AsyncLoggerContextSelector 
     }
 
     @Override
-    public LoggerContext getContext(String fqcn, ClassLoader loader,
-            boolean currentContext, URI configLocation) {
+    public LoggerContext getContext(String fqcn, ClassLoader loader, boolean currentContext,
URI configLocation) {
         return CONTEXT;
     }
 
+    @Override
+    public void removeContext(LoggerContext context) {
+    }
+
 }

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java?rev=1484363&r1=1484362&r2=1484363&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
Sun May 19 22:29:14 2013
@@ -105,4 +105,16 @@ public class Log4jContextFactory impleme
         }
         return ctx;
     }
+
+
+    /**
+     * Removes knowledge of a LoggerContext.
+     * @param The context to remove.
+     */
+    @Override
+    public void removeContext(org.apache.logging.log4j.spi.LoggerContext context) {
+        if (context instanceof LoggerContext) {
+            selector.removeContext((LoggerContext) context);
+        }
+    }
 }

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/selector/BasicContextSelector.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/selector/BasicContextSelector.java?rev=1484363&r1=1484362&r2=1484363&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/selector/BasicContextSelector.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/selector/BasicContextSelector.java
Sun May 19 22:29:14 2013
@@ -51,8 +51,8 @@ public class BasicContextSelector implem
         return CONTEXT;
     }
 
+    @Override
     public void removeContext(final LoggerContext context) {
-
     }
 
     @Override

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java?rev=1484363&r1=1484362&r2=1484363&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java
Sun May 19 22:29:14 2013
@@ -142,6 +142,7 @@ public class ClassLoaderContextSelector 
         }
     }
 
+    @Override
     public void removeContext(final LoggerContext context) {
         for (final Map.Entry<String, AtomicReference<WeakReference<LoggerContext>>>
entry : CONTEXT_MAP.entrySet()) {
             final LoggerContext ctx = entry.getValue().get().get();

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/selector/ContextSelector.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/selector/ContextSelector.java?rev=1484363&r1=1484362&r2=1484363&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/selector/ContextSelector.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/selector/ContextSelector.java
Sun May 19 22:29:14 2013
@@ -52,4 +52,10 @@ public interface ContextSelector {
      * @return The List of LoggerContexts.
      */
     List<LoggerContext> getLoggerContexts();
+
+    /**
+     * Remove any references to the LoggerContext.
+     * @param context The context to remove.
+     */
+    void removeContext(LoggerContext context);
 }

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/selector/JNDIContextSelector.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/selector/JNDIContextSelector.java?rev=1484363&r1=1484362&r2=1484363&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/selector/JNDIContextSelector.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/selector/JNDIContextSelector.java
Sun May 19 22:29:14 2013
@@ -133,6 +133,7 @@ public class JNDIContextSelector impleme
         return CONTEXT_MAP.get(name);
     }
 
+    @Override
     public void removeContext(final LoggerContext context) {
 
         for (final Map.Entry<String, LoggerContext> entry : CONTEXT_MAP.entrySet())
{

Modified: logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContextFactory.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContextFactory.java?rev=1484363&r1=1484362&r2=1484363&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContextFactory.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContextFactory.java
Sun May 19 22:29:14 2013
@@ -52,4 +52,8 @@ public class SLF4JLoggerContextFactory i
                                     URI configLocation) {
         return context;
     }
+
+    @Override
+    public void removeContext(LoggerContext context) {
+    }
 }

Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1484363&r1=1484362&r2=1484363&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Sun May 19 22:29:14 2013
@@ -22,6 +22,9 @@
   </properties>
   <body>
     <release version="2.0-beta7" date="2013-??-??" description="Bug fixes and enhancements">
+      <action issue="LOG4J2-223" dev="rgoers" type="fix">
+        Remove LoggerContext when LoggerContext is stopped.
+      </action>
       <action issue="LOG4J2-260" dev="ggregory" type="fix">
         XML layout does not specify charset in content type.
       </action>



Mime
View raw message