logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r1456324 - in /logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config: BaseConfiguration.java plugins/PluginManager.java
Date Thu, 14 Mar 2013 05:10:43 GMT
Author: sdeboy
Date: Thu Mar 14 05:10:42 2013
New Revision: 1456324

URL: http://svn.apache.org/r1456324
Log:
Implementing LOG4J2-175: Plugin cache should be reset when addPackages is called
 - updated PluginManager#addPackage to reset the pluginTypeMap if a package was added, causing
calls to PluginManager#collectPlugins to retrieve plugins instead of use the pluginTypeMap
cache
 - updated BaseConfiguration - removed pluginManager member, changed getPluginManager to construct
a new 'Core' instance and call collectPlugins on that instance prior to returning
 
 Resolves the issue where a packages definition on the configuration would not have any effect
due to cached plugins and a cached pluginmanager in the configuration

Modified:
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginManager.java

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java?rev=1456324&r1=1456323&r2=1456324&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java
Thu Mar 14 05:10:42 2013
@@ -69,11 +69,6 @@ public class BaseConfiguration extends A
     protected Node rootNode;
 
     /**
-     * The Plugin Manager.
-     */
-    protected PluginManager pluginManager;
-
-    /**
      * Listeners for configuration changes.
      */
     protected final List<ConfigurationListener> listeners =
@@ -109,7 +104,6 @@ public class BaseConfiguration extends A
      * Constructor.
      */
     protected BaseConfiguration() {
-        pluginManager = new PluginManager("Core");
         rootNode = new Node();
     }
 
@@ -121,7 +115,6 @@ public class BaseConfiguration extends A
      * Initialize the configuration.
      */
     public void start() {
-        pluginManager.collectPlugins();
         setup();
         doConfigure();
         for (final LoggerConfig logger : loggers.values()) {
@@ -243,7 +236,11 @@ public class BaseConfiguration extends A
     }
 
     protected PluginManager getPluginManager() {
-        return pluginManager;
+        //don't cache a pluginmanager instance - packages may be updated, requiring 
+        // re-discovery of plugins
+        PluginManager mgr = new PluginManager("Core");
+        mgr.collectPlugins();
+        return mgr;
     }
 
     /**

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginManager.java?rev=1456324&r1=1456323&r2=1456324&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginManager.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginManager.java
Thu Mar 14 05:10:42 2013
@@ -98,7 +98,11 @@ public class PluginManager {
      * @param p The package name.
      */
     public static void addPackage(final String p) {
-        PACKAGES.addIfAbsent(p);
+        if (PACKAGES.addIfAbsent(p))
+        {
+            //set of available plugins could have changed, reset plugin cache for newly-retrieved
managers
+            pluginTypeMap.clear();
+        }
     }
 
     /**



Mime
View raw message