You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2014/10/30 16:55:08 UTC
svn commit: r1635526 - in /qpid/trunk/qpid/java/broker-core/src:
main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
test/java/org/apache/qpid/server/model/AbstractConfiguredObjectTest.java
Author: orudyy
Date: Thu Oct 30 15:55:07 2014
New Revision: 1635526
URL: http://svn.apache.org/r1635526
Log:
QPID-6196: Add synchronization lock into AbstractConfiguredObject.unregisterChild
Modified:
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AbstractConfiguredObjectTest.java
Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java?rev=1635526&r1=1635525&r2=1635526&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java Thu Oct 30 15:55:07 2014
@@ -1443,9 +1443,12 @@ public abstract class AbstractConfigured
private <C extends ConfiguredObject> void unregisterChild(final C child)
{
Class categoryClass = child.getCategoryClass();
- _children.get(categoryClass).remove(child);
- _childrenById.get(categoryClass).remove(child.getId());
- _childrenByName.get(categoryClass).remove(child.getName());
+ synchronized(_children)
+ {
+ _children.get(categoryClass).remove(child);
+ _childrenById.get(categoryClass).remove(child.getId());
+ _childrenByName.get(categoryClass).remove(child.getName());
+ }
}
@Override
Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AbstractConfiguredObjectTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AbstractConfiguredObjectTest.java?rev=1635526&r1=1635525&r2=1635526&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AbstractConfiguredObjectTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AbstractConfiguredObjectTest.java Thu Oct 30 15:55:07 2014
@@ -615,122 +615,4 @@ public class AbstractConfiguredObjectTes
assertTrue(obj.getEnumSetValues().containsAll(Arrays.asList(TestEnum.TEST_ENUM2, TestEnum.TEST_ENUM3)));
}
}
-
- public void testCreateConcurrentlyChildrenWithTheSameName() throws Exception
- {
- final TestConfiguredObject parent = new TestConfiguredObject("parent");
- parent.create();
-
- short numberOfThreads = 300;
- ExecutorService executor = Executors.newFixedThreadPool(numberOfThreads);
-
- final CountDownLatch startLatch = new CountDownLatch(1);
- final CountDownLatch endLatch = new CountDownLatch(numberOfThreads);
- final AtomicInteger duplicateNameExceptionCounter = new AtomicInteger();
- final AtomicInteger successCounter = new AtomicInteger();
- try
- {
- for (int i = 0; i < numberOfThreads; i++)
- {
- executor.submit(new Runnable()
- {
- @Override
- public void run()
- {
- TestConfiguredObject child = new TestConfiguredObject("child", parent, parent.getTaskExecutor());
- try
- {
- startLatch.await();
- child.create();
- successCounter.incrementAndGet();
- }
- catch(AbstractConfiguredObject.DuplicateNameException e)
- {
- duplicateNameExceptionCounter.incrementAndGet();
- }
- catch (InterruptedException e)
- {
- // ignore
- }
- finally
- {
- endLatch.countDown();
- }
- }
- });
- }
- startLatch.countDown();
- assertTrue("Waiting interval expired", endLatch.await(10, TimeUnit.SECONDS));
- }
- finally
- {
- executor.shutdownNow();
- }
-
- assertEquals("Unexpected number of children", 1, parent.getChildren(TestConfiguredObject.class).size());
- assertEquals("Unexpected number of successful creations", 1, successCounter.get());
- assertEquals("Unexpected number of DuplicateNameException", numberOfThreads - 1, duplicateNameExceptionCounter.get());
- }
-
- public void testCreateConcurrentlyChildrenWithTheSameId() throws Exception
- {
- final TestConfiguredObject parent = new TestConfiguredObject("parent");
- parent.create();
-
- short numberOfThreads = 300;
- ExecutorService executor = Executors.newFixedThreadPool(numberOfThreads);
-
- final CountDownLatch startLatch = new CountDownLatch(1);
- final CountDownLatch endLatch = new CountDownLatch(numberOfThreads);
- final AtomicInteger duplicateIdExceptionCounter = new AtomicInteger();
- final AtomicInteger successCounter = new AtomicInteger();
- final UUID id = UUID.randomUUID();
- try
- {
- for (int i = 0; i < numberOfThreads; i++)
- {
- final int iteration = i;
- executor.submit(new Runnable()
- {
- @Override
- public void run()
- {
- Map<String, Object> attributes = new HashMap<>();
- attributes.put(ConfiguredObject.NAME, "child-" + iteration);
- attributes.put(ConfiguredObject.ID, id);
- TestConfiguredObject child = new TestConfiguredObject(parent, attributes);
-
- try
- {
- startLatch.await();
- child.create();
- successCounter.incrementAndGet();
- }
- catch(AbstractConfiguredObject.DuplicateIdException e)
- {
- duplicateIdExceptionCounter.incrementAndGet();
- }
- catch (InterruptedException e)
- {
- // ignore
- }
- finally
- {
- endLatch.countDown();
- }
- }
- });
- }
- startLatch.countDown();
- assertTrue("Waiting interval expired", endLatch.await(10, TimeUnit.SECONDS));
- }
- finally
- {
- executor.shutdownNow();
- }
-
- assertEquals("Unexpected number of children", 1, parent.getChildren(TestConfiguredObject.class).size());
- assertEquals("Unexpected number of successful creations", 1, successCounter.get());
- assertEquals("Unexpected number of DuplicateIdException", numberOfThreads - 1, duplicateIdExceptionCounter.get());
- }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org