mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-22060: Reader on the backing store is obtained only once in CachingContentStore (#329)
This commit is contained in:
committed by
eknizat
parent
fa43cb52dc
commit
e8da151640
@@ -206,7 +206,7 @@ public class CachingContentStore implements ContentStore, ApplicationEventPublis
|
||||
return backingStoreReader;
|
||||
}
|
||||
|
||||
ContentReader reader = attemptCacheAndRead(url);
|
||||
ContentReader reader = attemptCacheAndRead(url, backingStoreReader);
|
||||
|
||||
if (reader != null)
|
||||
{
|
||||
@@ -254,14 +254,14 @@ public class CachingContentStore implements ContentStore, ApplicationEventPublis
|
||||
* @param url URL to cache.
|
||||
* @return A reader onto the cached content file or null if unable to provide one.
|
||||
*/
|
||||
private ContentReader attemptCacheAndRead(String url)
|
||||
private ContentReader attemptCacheAndRead(String url, ContentReader backingStoreReader)
|
||||
{
|
||||
ContentReader reader = null;
|
||||
try
|
||||
{
|
||||
if (!cache.contains(url))
|
||||
{
|
||||
if (cache.put(url, backingStore.getReader(url)))
|
||||
if (cache.put(url, backingStoreReader))
|
||||
{
|
||||
reader = cache.getReader(url);
|
||||
}
|
||||
|
@@ -38,6 +38,7 @@ import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.only;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -121,6 +122,8 @@ public class CachingContentStoreTest
|
||||
|
||||
assertSame(returnedReader, cachedContent);
|
||||
verify(quota).afterWritingCacheFile(1274L);
|
||||
// Check backing store reader is only acquired once
|
||||
verify(backingStore, only()).getReader("url");
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user