mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fixed transactional cache when new entry was created concurrently with a clear: ALFCOM-3457
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@17051 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
*/
|
||||
package org.alfresco.repo.cache;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -34,6 +33,7 @@ import javax.transaction.UserTransaction;
|
||||
import junit.framework.TestCase;
|
||||
import net.sf.ehcache.CacheManager;
|
||||
|
||||
import org.alfresco.repo.cache.TransactionalCache.NullValueMarker;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.repo.transaction.TransactionListenerAdapter;
|
||||
@@ -192,7 +192,9 @@ public class CacheTest extends TestCase
|
||||
// update 3 in the cache
|
||||
transactionalCache.put(updatedTxnThree, "XXX");
|
||||
assertEquals("Item not updated in txn cache", "XXX", transactionalCache.get(updatedTxnThree));
|
||||
assertFalse("Item was put into backing cache", backingCache.contains(updatedTxnThree));
|
||||
assertFalse("Item was put into backing cache (excl. NullValueMarker)",
|
||||
backingCache.contains(updatedTxnThree) &&
|
||||
!(backingCache.get(updatedTxnThree) instanceof NullValueMarker));
|
||||
|
||||
// check that the keys collection is correct
|
||||
Collection<String> transactionalKeys = transactionalCache.getKeys();
|
||||
@@ -437,7 +439,7 @@ public class CacheTest extends TestCase
|
||||
}
|
||||
|
||||
/** Execute the callback and ensure that the backing cache is left with the expected value */
|
||||
private void executeAndCheck(RetryingTransactionCallback<Object> callback, Serializable key, Object expectedValue) throws Throwable
|
||||
private void executeAndCheck(RetryingTransactionCallback<Object> callback, String key, Object expectedValue) throws Throwable
|
||||
{
|
||||
TransactionService transactionService = serviceRegistry.getTransactionService();
|
||||
UserTransaction txn = transactionService.getUserTransaction();
|
||||
@@ -451,6 +453,15 @@ public class CacheTest extends TestCase
|
||||
{
|
||||
try { txn.rollback(); } catch (Throwable ee) {}
|
||||
}
|
||||
Object actualValue = backingCache.get(key);
|
||||
if (expectedValue == null)
|
||||
{
|
||||
assertNull("Expected backing cache to have null", actualValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
assertEquals("Backing cache value was not correct", expectedValue, actualValue);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String COMMON_KEY = "A";
|
||||
@@ -493,7 +504,7 @@ public class CacheTest extends TestCase
|
||||
return null;
|
||||
}
|
||||
};
|
||||
executeAndCheck(callback, COMMON_KEY, commonValue);
|
||||
executeAndCheck(callback, COMMON_KEY, null);
|
||||
}
|
||||
/**
|
||||
* <ul>
|
||||
|
Reference in New Issue
Block a user