commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcucchi...@apache.org
Subject svn commit: r1197043 - /commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/enhance/ExpressionCompiler.java
Date Thu, 03 Nov 2011 10:17:21 GMT
Author: mcucchiara
Date: Thu Nov  3 10:17:21 2011
New Revision: 1197043

URL: http://svn.apache.org/viewvc?rev=1197043&view=rev
Log:
OGNL-37 - Avoid concurrentModificationException

Modified:
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/enhance/ExpressionCompiler.java

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/enhance/ExpressionCompiler.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/enhance/ExpressionCompiler.java?rev=1197043&r1=1197042&r2=1197043&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/enhance/ExpressionCompiler.java
(original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/enhance/ExpressionCompiler.java
Thu Nov  3 10:17:21 2011
@@ -675,15 +675,15 @@ public class ExpressionCompiler
         throws NotFoundException, CannotCompileException
     {
         Map<String, LocalReference> referenceMap = context.getLocalReferences();
-        if ( referenceMap == null || referenceMap.size() < 1 )
+        if ( referenceMap == null || referenceMap.isEmpty() )
         {
             return;
         }
 
-        for ( Map.Entry<String, LocalReference> entry : referenceMap.entrySet() )
+        Iterator<LocalReference> it = referenceMap.values().iterator();
+        while( it.hasNext() )
         {
-            LocalReference ref = entry.getValue();
-            String key = entry.getKey();
+            LocalReference ref = it.next();
             String widener = ref.getType().isPrimitive() ? " " : " ($w) ";
 
             String body = format( "{ return %s %s; }", widener, ref.getExpression() ).replaceAll(
"\\.\\.", "." );
@@ -696,7 +696,7 @@ public class ExpressionCompiler
             method.setBody( body );
 
             clazz.addMethod( method );
-            referenceMap.remove( key );
+            it.remove();
         }
     }
 



Mime
View raw message