From f360f5fe3c0de4442b42e41b188ecb7d5b1e7c7c Mon Sep 17 00:00:00 2001 From: Dave Ward Date: Tue, 27 Oct 2009 10:36:43 +0000 Subject: [PATCH] Merged V3.2 to HEAD 17171: Possible fix to latest intermittent concurrency issues in V3.2 build - PersonTest needs to do its ref checking in a new transaction and concurrent hash map used for thread safety - Thread safety of ReaderManagementPool singleton git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@17173 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/security/person/PersonTest.java | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/source/java/org/alfresco/repo/security/person/PersonTest.java b/source/java/org/alfresco/repo/security/person/PersonTest.java index 1163bb09fb..2cc33c7520 100644 --- a/source/java/org/alfresco/repo/security/person/PersonTest.java +++ b/source/java/org/alfresco/repo/security/person/PersonTest.java @@ -29,6 +29,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -576,7 +577,7 @@ public class PersonTest extends BaseSpringTest int threadCount = 10; final CountDownLatch startLatch = new CountDownLatch(threadCount); final CountDownLatch endLatch = new CountDownLatch(threadCount); - final Map cleanableNodeRefs = new HashMap(17); + final Map cleanableNodeRefs = new ConcurrentHashMap(17); Runnable createPersonRunnable = new Runnable() { public void run() @@ -642,19 +643,26 @@ public class PersonTest extends BaseSpringTest return personService.getPerson(duplicateUsername); } }; - NodeRef remainingNodeRef = transactionService.getRetryingTransactionHelper().doInTransaction(getPersonWork, false, true); - // Should all be cleaned up now, but no way to check - for (NodeRef nodeRef : cleanableNodeRefs.values()) - { - if (nodeRef.equals(remainingNodeRef)) + final NodeRef remainingNodeRef = transactionService.getRetryingTransactionHelper().doInTransaction(getPersonWork, false, true); + transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback(){ + + public Object execute() throws Throwable { - // This one should still be around - continue; + // Should all be cleaned up now, but no way to check + for (NodeRef nodeRef : cleanableNodeRefs.values()) + { + if (nodeRef.equals(remainingNodeRef)) + { + // This one should still be around + continue; + } + if (nodeService.exists(nodeRef)) + { + fail("Expected unused person noderef to have been cleaned up: " + nodeRef); + } + } + return null; } - if (nodeService.exists(nodeRef)) - { - fail("Expected unused person noderef to have been cleaned up: " + nodeRef); - } - } + }, true, true); } }