commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r1301177 - /commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/binder/AbstractRulesModule.java
Date Thu, 15 Mar 2012 23:10:43 GMT
On 15 March 2012 20:09,  <simonetripodi@apache.org> wrote:
> Author: simonetripodi
> Date: Thu Mar 15 20:09:31 2012
> New Revision: 1301177
>
> URL: http://svn.apache.org/viewvc?rev=1301177&view=rev
> Log:
> potential fix for [DIGESTER-163]

If the problem is due to multi-threading issues, isn't that because
the same instance is being shared between threads, presumably on
purpose?

If so, using ThreadLocal may fix the immediate problem, but won't it
prevent the data being shared?

> Modified:
>    commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/binder/AbstractRulesModule.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=1301177&r1=1301176&r2=1301177&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
Thu Mar 15 20:09:31 2012
> @@ -28,26 +28,26 @@ public abstract class AbstractRulesModul
>     implements RulesModule
>  {
>
> -    private RulesBinder rulesBinder;
> +    private final ThreadLocal<RulesBinder> rulesBinders = new ThreadLocal<RulesBinder>();
>
>     /**
>      * {@inheritDoc}
>      */
>     public final void configure( RulesBinder rulesBinder )
>     {
> -        if ( this.rulesBinder != null )
> +        if ( rulesBinders.get() != null )
>         {
>             throw new IllegalStateException( "Re-entry is not allowed." );
>         }
>
> -        this.rulesBinder = rulesBinder;
> +        rulesBinders.set( rulesBinder );
>         try
>         {
>             configure();
>         }
>         finally
>         {
> -            this.rulesBinder = null;
> +            rulesBinders.remove();
>         }
>     }
>
> @@ -68,7 +68,7 @@ public abstract class AbstractRulesModul
>      */
>     protected void addError( String messagePattern, Object... arguments )
>     {
> -        rulesBinder.addError( messagePattern, arguments );
> +        rulesBinders.get().addError( messagePattern, arguments );
>     }
>
>     /**
> @@ -80,7 +80,7 @@ public abstract class AbstractRulesModul
>      */
>     protected void addError( Throwable t )
>     {
> -        rulesBinder.addError( t );
> +        rulesBinders.get().addError( t );
>     }
>
>     /**
> @@ -91,7 +91,7 @@ public abstract class AbstractRulesModul
>      */
>     protected void install( RulesModule rulesModule )
>     {
> -        rulesBinder.install( rulesModule );
> +        rulesBinders.get().install( rulesModule );
>     }
>
>     /**
> @@ -103,7 +103,7 @@ public abstract class AbstractRulesModul
>      */
>     protected LinkedRuleBuilder forPattern( String pattern )
>     {
> -        return rulesBinder.forPattern( pattern );
> +        return rulesBinders.get().forPattern( pattern );
>     }
>
>     /**
> @@ -113,7 +113,7 @@ public abstract class AbstractRulesModul
>      */
>     protected RulesBinder rulesBinder()
>     {
> -        return rulesBinder;
> +        return rulesBinders.get();
>     }
>
>  }
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message