Fixed ALF-1562: AuditModelRegistry and audit loading can fail when started on demand

- Transactional caches in nested transactions force the outer txn caches to drop new data
 - Forces a requery of transactional data in case the inner transaction caused it to go stale


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18868 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2010-02-25 23:46:34 +00:00
parent f8c7f7432d
commit 44d2fc6bec
2 changed files with 112 additions and 2 deletions

View File

@@ -163,6 +163,41 @@ public class CacheTest extends TestCase
txnHelper.doInTransaction(callback);
}
/**
* Make sure that an outer transaction gets to see cached data modified by an inner transaction.
*/
public void testOuterTransactionStaleDataAvoidance() throws Throwable
{
final TransactionService transactionService = serviceRegistry.getTransactionService();
RetryingTransactionCallback<Void> outer = new RetryingTransactionCallback<Void>()
{
public Void execute() throws Throwable
{
// Put a value in the cache
transactionalCache.put("A", "OUTER");
assertNotNull("Expected to get a value before inner txn.", transactionalCache.get("A"));
RetryingTransactionCallback<Void> inner = new RetryingTransactionCallback<Void>()
{
public Void execute() throws Throwable
{
// Just update the cache
transactionalCache.put("A", "INNER");
return null;
}
};
// Do it in a nested txn
transactionService.getRetryingTransactionHelper().doInTransaction(inner, false, true);
assertNull("Expected to *not* get a value after inner txn.", transactionalCache.get("A"));
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(outer);
}
public void testTransactionalCacheWithSingleTxn() throws Throwable
{
String newGlobalOne = "new_global_one";
@@ -345,7 +380,7 @@ public class CacheTest extends TestCase
}
/**
* Tests a straight Ehcache adapter against a transactional cache both in and out
* Tests a straight Ehcache adapter against a transactional cache both in and outprojects/repository/source/java/org/alfresco/repo/cache/TransactionalCache.java
* of a transaction. This is done repeatedly, pushing the count up.
*/
public void testPerformance() throws Exception