myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdebussc...@apache.org
Subject svn commit: r1196622 - /myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/factory/AbstractNameMapperAwareFactory.java
Date Wed, 02 Nov 2011 15:21:00 GMT
Author: rdebusscher
Date: Wed Nov  2 15:20:59 2011
New Revision: 1196622

URL: http://svn.apache.org/viewvc?rev=1196622&view=rev
Log:
EXTVAL-137 : Deregistering a class from the NameMapperFactory results in unsupported operation
on CopyOnWriteArrayList

Modified:
    myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/factory/AbstractNameMapperAwareFactory.java

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/factory/AbstractNameMapperAwareFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/factory/AbstractNameMapperAwareFactory.java?rev=1196622&r1=1196621&r2=1196622&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/factory/AbstractNameMapperAwareFactory.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/factory/AbstractNameMapperAwareFactory.java
Wed Nov  2 15:20:59 2011
@@ -79,8 +79,18 @@ public abstract class AbstractNameMapper
             subNameMapper = true;
         }
 
-        Iterator<NameMapper<T>> nameMapperIterator = getNameMapperList().iterator();
-
+        List<NameMapper<T>> nameMapperList = getNameMapperList();
+        List<NameMapper<T>> changeableList;
+        if (!subNameMapper && (getNameMapperList() instanceof CopyOnWriteArrayList))
+        {
+            // If we have a CopyOnWriteArrayList, we can't remove it so copy it to a temporary
list
+            changeableList = new ArrayList<NameMapper<T>>(nameMapperList);
+        }
+        else
+        {
+            changeableList = nameMapperList;
+        }
+        Iterator<NameMapper<T>> nameMapperIterator = changeableList.iterator();
         while (nameMapperIterator.hasNext())
         {
             if (subNameMapper)
@@ -100,6 +110,13 @@ public abstract class AbstractNameMapper
                     //break;
                 }
             }
+            if (!subNameMapper && (getNameMapperList() instanceof CopyOnWriteArrayList))
+            {
+                // Set the correct content back in the CopyOnWriteArrayList
+                getNameMapperList().clear();
+                getNameMapperList().addAll(changeableList);
+            }
+
         }
     }
 



Mime
View raw message