This is an automated email from the ASF dual-hosted git repository. billblough pushed a commit to branch 1_5 in repository https://gitbox.apache.org/repos/asf/axis-axis2-java-core.git
commit 3309b80ebefdae766ee9bfc8edaa999921d58be7 Author: Andreas Veithen <veit...@apache.org> AuthorDate: Mon Sep 5 09:50:02 2011 +0000 Merged r1037135 and r1037218 to the 1.5 branch to fix the ConcurrentModificationException that sometimes causes the Hudson build to fail. --- .../axis2/jaxws/client/ReleaseServiceTests.java | 8 ------- .../description/impl/DescriptionFactoryImpl.java | 28 ++++++++++++---------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/modules/jaxws/test/org/apache/axis2/jaxws/client/ReleaseServiceTests.java b/modules/jaxws/test/org/apache/axis2/jaxws/client/ReleaseServiceTests.java index 803393a..36e143c 100644 --- a/modules/jaxws/test/org/apache/axis2/jaxws/client/ReleaseServiceTests.java +++ b/modules/jaxws/test/org/apache/axis2/jaxws/client/ReleaseServiceTests.java @@ -84,8 +84,6 @@ public class ReleaseServiceTests extends TestCase { epDesc= svcDesc.getEndpointDescription(portQN, delegate); assertNull(epDesc); - } catch (Throwable t) { - fail("Caught throwable " + t); } finally { ClientMetadataTest.restoreOriginalFactory(); } @@ -107,8 +105,6 @@ public class ReleaseServiceTests extends TestCase { svc1.addPort(portQN, bindingID1, epr1); } org.apache.axis2.jaxws.spi.ServiceDelegate.releaseService(svc1); - } catch (Throwable t) { - fail("Caught throwable " + t); } finally { ClientMetadataTest.restoreOriginalFactory(); } @@ -135,8 +131,6 @@ public class ReleaseServiceTests extends TestCase { } org.apache.axis2.jaxws.spi.ServiceDelegate.releaseService(svc1); } - } catch (Throwable t) { - fail("Caught throwable " + t); } finally { ClientMetadataTest.restoreOriginalFactory(); } @@ -541,8 +535,6 @@ public class ReleaseServiceTests extends TestCase { ClientMetadataPortSEI port = genSvc.getPort(ClientMetadataPortSEI.class); org.apache.axis2.jaxws.spi.ServiceDelegate.releaseService(genSvc); } - } catch (Throwable t) { - fail("Caught throwable " + t); } finally { ClientMetadataTest.restoreOriginalFactory(); } diff --git a/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java b/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java index 51e352f..7003807 100644 --- a/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java +++ b/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java @@ -503,18 +503,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"); + } } } }