mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fixed ALF-10665: Immutable caches do not respond well to null (=> @@VALUE_NOT_FOUND@@)
- Immutable caches assume that values are correct and write through - Null value markers will get overridden git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31144 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -774,6 +774,33 @@ public class CacheTest extends TestCase
|
||||
executeAndCheck(callback, false, COMMON_KEY, null);
|
||||
executeAndCheck(callback, true, COMMON_KEY, null);
|
||||
}
|
||||
/**
|
||||
* <ul>
|
||||
* <li>Remove from the backing cache</li>
|
||||
* <li>Add to the transactional cache</li>
|
||||
* <li>Add to the backing cache</li>
|
||||
* <li>Commit</li>
|
||||
* </ul>
|
||||
*/
|
||||
public void testConcurrentAddAgainstAdd_NoPreExisting()throws Throwable
|
||||
{
|
||||
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
|
||||
{
|
||||
public Object execute() throws Throwable
|
||||
{
|
||||
backingCache.remove(COMMON_KEY);
|
||||
transactionalCache.put(COMMON_KEY, "aaa2-x");
|
||||
backingCache.put(COMMON_KEY, "aaa2");
|
||||
return null;
|
||||
}
|
||||
};
|
||||
transactionalCache.setMutable(true);
|
||||
executeAndCheck(callback, false, COMMON_KEY, null);
|
||||
executeAndCheck(callback, true, COMMON_KEY, "aaa2"); // Doesn't write through
|
||||
transactionalCache.setMutable(false);
|
||||
executeAndCheck(callback, false, COMMON_KEY, "aaa2-x"); // Always overwrites
|
||||
executeAndCheck(callback, true, COMMON_KEY, "aaa2-x"); // Always overwrites
|
||||
}
|
||||
/**
|
||||
* <ul>
|
||||
* <li>Add to the backing cache</li>
|
||||
|
@@ -838,12 +838,9 @@ public class TransactionalCache<K extends Serializable, V extends Object>
|
||||
Object sharedObj = sharedCache.get(key);
|
||||
if (!mutable)
|
||||
{
|
||||
// Value can't change
|
||||
if (sharedObj == null)
|
||||
{
|
||||
// Still nothing in the cache
|
||||
sharedCache.put(key, value);
|
||||
}
|
||||
// The value can't change so we can write through on the assumption
|
||||
// that the value is always correct
|
||||
sharedCache.put(key, value);
|
||||
}
|
||||
else if (readOnly)
|
||||
{
|
||||
|
Reference in New Issue
Block a user