You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mc...@apache.org on 2011/11/03 11:17:21 UTC
svn commit: r1197043 -
/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/enhance/ExpressionCompiler.java
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();
}
}