commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1301493 - /commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/xmlrules/FromXmlRulesModule.java
Date Fri, 16 Mar 2012 13:29:34 GMT
Author: simonetripodi
Date: Fri Mar 16 13:29:34 2012
New Revision: 1301493

URL: http://svn.apache.org/viewvc?rev=1301493&view=rev
Log:
check already bound rules per thread and not tracking them globally, otherwise threads are
cheated

Modified:
    commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/xmlrules/FromXmlRulesModule.java

Modified: commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/xmlrules/FromXmlRulesModule.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/xmlrules/FromXmlRulesModule.java?rev=1301493&r1=1301492&r2=1301493&view=diff
==============================================================================
--- commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/xmlrules/FromXmlRulesModule.java
(original)
+++ commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/xmlrules/FromXmlRulesModule.java
Fri Mar 16 13:29:34 2012
@@ -52,7 +52,7 @@ public abstract class FromXmlRulesModule
 
     private final URL xmlRulesDtdUrl = FromXmlRulesModule.class.getResource( DIGESTER_DTD_PATH
);
 
-    private final Set<String> systemIds = new HashSet<String>();
+    private final ThreadLocal<Set<String>> systemIds = new ThreadLocal<Set<String>>();
 
     private String rootPath;
 
@@ -62,18 +62,19 @@ public abstract class FromXmlRulesModule
     @Override
     protected void configure()
     {
-        if ( !systemIds.isEmpty() )
+        if ( systemIds.get() != null )
         {
             throw new IllegalStateException( "Re-entry is not allowed." );
         }
 
+        systemIds.set( new HashSet<String>() );
         try
         {
             loadRules();
         }
         finally
         {
-            systemIds.clear();
+            systemIds.remove();
         }
     }
 
@@ -95,7 +96,7 @@ public abstract class FromXmlRulesModule
         }
 
         String systemId = inputSource.getSystemId();
-        if ( systemId != null && !systemIds.add( systemId ) )
+        if ( systemId != null && !systemIds.get().add( systemId ) )
         {
             addError( "XML rules file '%s' already bound", systemId );
         }
@@ -253,7 +254,7 @@ public abstract class FromXmlRulesModule
      */
     public final Set<String> getSystemIds()
     {
-        return unmodifiableSet( systemIds );
+        return unmodifiableSet( systemIds.get() );
     }
 
 }



Mime
View raw message