commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1301815 - in /commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/binder: AbstractRulesModule.java DigesterLoader.java
Date Fri, 16 Mar 2012 23:01:39 GMT
Author: simonetripodi
Date: Fri Mar 16 23:01:39 2012
New Revision: 1301815

URL: http://svn.apache.org/viewvc?rev=1301815&view=rev
Log:
[DIGESTER-163] no needs of RulesBinder lazy loading, no needs to store RulesBinder in ThreadLocal,
attempt to resolve concurrent issues

Modified:
    commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/binder/AbstractRulesModule.java
    commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/binder/DigesterLoader.java

Modified: commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/binder/AbstractRulesModule.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/binder/AbstractRulesModule.java?rev=1301815&r1=1301814&r2=1301815&view=diff
==============================================================================
--- commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/binder/AbstractRulesModule.java
(original)
+++ commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/binder/AbstractRulesModule.java
Fri Mar 16 23:01:39 2012
@@ -28,26 +28,26 @@ public abstract class AbstractRulesModul
     implements RulesModule
 {
 
-    private final ThreadLocal<RulesBinder> rulesBinders = new ThreadLocal<RulesBinder>();
+    private RulesBinder rulesBinder;
 
     /**
      * {@inheritDoc}
      */
     public final void configure( RulesBinder rulesBinder )
     {
-        if ( rulesBinders.get() != null )
+        if ( this.rulesBinder != null )
         {
             throw new IllegalStateException( "Re-entry is not allowed." );
         }
 
-        rulesBinders.set( rulesBinder );
+        this.rulesBinder = rulesBinder;
         try
         {
             configure();
         }
         finally
         {
-            rulesBinders.remove();
+            this.rulesBinder = null;
         }
     }
 
@@ -68,7 +68,7 @@ public abstract class AbstractRulesModul
      */
     protected void addError( String messagePattern, Object... arguments )
     {
-        rulesBinders.get().addError( messagePattern, arguments );
+        rulesBinder.addError( messagePattern, arguments );
     }
 
     /**
@@ -80,7 +80,7 @@ public abstract class AbstractRulesModul
      */
     protected void addError( Throwable t )
     {
-        rulesBinders.get().addError( t );
+        rulesBinder.addError( t );
     }
 
     /**
@@ -91,7 +91,7 @@ public abstract class AbstractRulesModul
      */
     protected void install( RulesModule rulesModule )
     {
-        rulesBinders.get().install( rulesModule );
+        rulesBinder.install( rulesModule );
     }
 
     /**
@@ -103,7 +103,7 @@ public abstract class AbstractRulesModul
      */
     protected LinkedRuleBuilder forPattern( String pattern )
     {
-        return rulesBinders.get().forPattern( pattern );
+        return rulesBinder.forPattern( pattern );
     }
 
     /**
@@ -113,7 +113,7 @@ public abstract class AbstractRulesModul
      */
     protected RulesBinder rulesBinder()
     {
-        return rulesBinders.get();
+        return rulesBinder;
     }
 
 }

Modified: commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/binder/DigesterLoader.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/binder/DigesterLoader.java?rev=1301815&r1=1301814&r2=1301815&view=diff
==============================================================================
--- commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/binder/DigesterLoader.java
(original)
+++ commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/binder/DigesterLoader.java
Fri Mar 16 23:01:39 2012
@@ -199,6 +199,13 @@ public final class DigesterLoader
         }
 
         this.classLoader = createBinderClassLoader( classLoader );
+
+        rulesBinder.initialize( this.classLoader );
+        for ( RulesModule rulesModule : rulesModules )
+        {
+            rulesModule.configure( rulesBinder );
+        }
+
         return this;
     }
 
@@ -594,15 +601,6 @@ public final class DigesterLoader
      */
     public RuleSet createRuleSet()
     {
-        if ( classLoader != rulesBinder.getContextClassLoader() )
-        {
-            rulesBinder.initialize( classLoader );
-            for ( RulesModule rulesModule : rulesModules )
-            {
-                rulesModule.configure( rulesBinder );
-            }
-        }
-
         if ( rulesBinder.hasError() )
         {
             Formatter fmt = new Formatter().format( HEADING );



Mime
View raw message