Author: veithen Date: Sat Nov 20 14:04:29 2010 New Revision: 1037218 URL: http://svn.apache.org/viewvc?rev=1037218&view=rev Log: Attempt to fix the ConcurrentModificationException that sometimes causes the Hudson build to fail.
Modified: axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java Modified: axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java?rev=1037218&r1=1037217&r2=1037218&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java (original) +++ axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java Sat Nov 20 14:04:29 2010 @@ -513,18 +513,22 @@ public class DescriptionFactoryImpl { log.debug("ServiceDescription not in use; will be removed from cache"); } svcDescRemoved = true; - Set<Map.Entry<DescriptionKey, ServiceDescription>> cacheEntrySet = - cache.entrySet(); - Iterator<Map.Entry<DescriptionKey, ServiceDescription>> cacheEntryIterator = - cacheEntrySet.iterator(); - while (cacheEntryIterator.hasNext()) { - Map.Entry<DescriptionKey, ServiceDescription> entry = - cacheEntryIterator.next(); - ServiceDescription entrySvcDescValue = entry.getValue(); - if (svcDesc == entrySvcDescValue) { - cacheEntryIterator.remove(); - if (log.isDebugEnabled()) { - log.debug("Removed service description from cache"); + // Even if we use a Hashtable, we need to synchronize here to avoid + // ConcurrentModificationException when iterating over the entries. + synchronized (cache) { + Set<Map.Entry<DescriptionKey, ServiceDescription>> cacheEntrySet = + cache.entrySet(); + Iterator<Map.Entry<DescriptionKey, ServiceDescription>> cacheEntryIterator = + cacheEntrySet.iterator(); + while (cacheEntryIterator.hasNext()) { + Map.Entry<DescriptionKey, ServiceDescription> entry = + cacheEntryIterator.next(); + ServiceDescription entrySvcDescValue = entry.getValue(); + if (svcDesc == entrySvcDescValue) { + cacheEntryIterator.remove(); + if (log.isDebugEnabled()) { + log.debug("Removed service description from cache"); + } } } }