Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)

84033: Merged V4.2-BUG-FIX (4.2.4) to HEAD-BUG-FIX (5.0/Cloud)
      83385: MNT-12297: TransactionalCache equality checks lead to false negatives in a cluster
       - TransactionalCache uses ValueHolder to store values put into the cache.
       - Each ValueHolder will have a new random integer to distinguish it from the next
       - TransactionalCache equality checks no longer use reference equality and instead
         use the ValueHolder.equals() method for most cases.  This actual client value
         .equals() is used where 'allowEquals' is true.
       - Immutable caches always assume the backing cache is correct, still.
      83391: Fix test doing checks in low-level cache (r83385 MNT-12297)


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@84621 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2014-09-18 17:21:11 +00:00
parent 610afaf8a5
commit fa4d74fa5b
5 changed files with 496 additions and 225 deletions

View File

@@ -42,6 +42,8 @@ import java.util.Set;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.cache.SimpleCache;
import org.alfresco.repo.cache.TransactionalCache;
import org.alfresco.repo.cache.TransactionalCache.ValueHolder;
import org.alfresco.repo.domain.node.Node;
import org.alfresco.repo.domain.node.NodeDAO;
import org.alfresco.repo.domain.node.NodeEntity;
@@ -128,9 +130,9 @@ public class NodeServiceTest
private static TransactionService txnService;
private static PolicyComponent policyComponent;
private static CannedQueryDAO cannedQueryDAOForTesting;
private static SimpleCache<Serializable, Serializable> nodesCache;
private static SimpleCache<Serializable, Serializable> propsCache;
private static SimpleCache<Serializable, Serializable> aspectsCache;
private static SimpleCache<Serializable, ValueHolder<Serializable>> nodesCache;
private static SimpleCache<Serializable, ValueHolder<Serializable>> propsCache;
private static SimpleCache<Serializable, ValueHolder<Serializable>> aspectsCache;
private static Long deletedTypeQNameId;
@@ -151,9 +153,9 @@ public class NodeServiceTest
cannedQueryDAOForTesting = (CannedQueryDAO) APP_CONTEXT_INIT.getApplicationContext().getBean("cannedQueryDAOForTesting");
// Get the caches for later testing
nodesCache = (SimpleCache<Serializable, Serializable>) APP_CONTEXT_INIT.getApplicationContext().getBean("node.nodesSharedCache");
propsCache = (SimpleCache<Serializable, Serializable>) APP_CONTEXT_INIT.getApplicationContext().getBean("node.propertiesSharedCache");
aspectsCache = (SimpleCache<Serializable, Serializable>) APP_CONTEXT_INIT.getApplicationContext().getBean("node.aspectsSharedCache");
nodesCache = (SimpleCache<Serializable, ValueHolder<Serializable>>) APP_CONTEXT_INIT.getApplicationContext().getBean("node.nodesSharedCache");
propsCache = (SimpleCache<Serializable, ValueHolder<Serializable>>) APP_CONTEXT_INIT.getApplicationContext().getBean("node.propertiesSharedCache");
aspectsCache = (SimpleCache<Serializable, ValueHolder<Serializable>>) APP_CONTEXT_INIT.getApplicationContext().getBean("node.aspectsSharedCache");
// Clear the caches to remove fluff
nodesCache.clear();
@@ -812,7 +814,7 @@ public class NodeServiceTest
/**
* Looks for a key that contains the toString() of the value
*/
private Object findCacheValue(SimpleCache<Serializable, Serializable> cache, Serializable key)
private Object findCacheValue(SimpleCache<Serializable, ValueHolder<Serializable>> cache, Serializable key)
{
Collection<Serializable> keys = cache.getKeys();
for (Serializable keyInCache : keys)
@@ -821,7 +823,7 @@ public class NodeServiceTest
String keyStr = key.toString();
if (keyInCacheStr.endsWith(keyStr))
{
Object value = cache.get(keyInCache);
Object value = TransactionalCache.getSharedCacheValue(cache, keyInCache);
return value;
}
}