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
This commit is contained in:
Dave Ward
2009-10-27 10:36:43 +00:00
parent b8aaa9c372
commit f360f5fe3c

View File

@@ -29,6 +29,7 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@@ -576,7 +577,7 @@ public class PersonTest extends BaseSpringTest
int threadCount = 10; int threadCount = 10;
final CountDownLatch startLatch = new CountDownLatch(threadCount); final CountDownLatch startLatch = new CountDownLatch(threadCount);
final CountDownLatch endLatch = new CountDownLatch(threadCount); final CountDownLatch endLatch = new CountDownLatch(threadCount);
final Map<String, NodeRef> cleanableNodeRefs = new HashMap<String, NodeRef>(17); final Map<String, NodeRef> cleanableNodeRefs = new ConcurrentHashMap<String, NodeRef>(17);
Runnable createPersonRunnable = new Runnable() Runnable createPersonRunnable = new Runnable()
{ {
public void run() public void run()
@@ -642,19 +643,26 @@ public class PersonTest extends BaseSpringTest
return personService.getPerson(duplicateUsername); return personService.getPerson(duplicateUsername);
} }
}; };
NodeRef remainingNodeRef = transactionService.getRetryingTransactionHelper().doInTransaction(getPersonWork, false, true); final NodeRef remainingNodeRef = transactionService.getRetryingTransactionHelper().doInTransaction(getPersonWork, false, true);
// Should all be cleaned up now, but no way to check transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>(){
for (NodeRef nodeRef : cleanableNodeRefs.values())
{ public Object execute() throws Throwable
if (nodeRef.equals(remainingNodeRef))
{ {
// This one should still be around // Should all be cleaned up now, but no way to check
continue; 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)) }, true, true);
{
fail("Expected unused person noderef to have been cleaned up: " + nodeRef);
}
}
} }
} }