CLOUDSTACK-7539: no return in synchronised block

This commit is contained in:
Daan Hoogland 2015-07-17 11:07:57 +02:00
parent 780816ee9f
commit c3d28e1b96

View File

@ -223,7 +223,7 @@ public class StorageCacheManagerImpl implements StorageCacheManager, Manager {
@Override @Override
public DataObject createCacheObject(DataObject data, DataStore store) { public DataObject createCacheObject(DataObject data, DataStore store) {
DataObject objOnCacheStore; DataObject objOnCacheStore = null;
final Object lock; final Object lock;
final DataObjectType type = data.getType(); final DataObjectType type = data.getType();
final String typeName; final String typeName;
@ -249,6 +249,7 @@ public class StorageCacheManagerImpl implements StorageCacheManager, Manager {
} }
s_logger.debug("check " + typeName + " cache entry(id: " + dataId + ") on store(id: " + storeId + ")"); s_logger.debug("check " + typeName + " cache entry(id: " + dataId + ") on store(id: " + storeId + ")");
DataObject existingDataObj = null;
synchronized (lock) { synchronized (lock) {
DataObjectInStore obj = objectInStoreMgr.findObject(data, store); DataObjectInStore obj = objectInStoreMgr.findObject(data, store);
if (obj != null) { if (obj != null) {
@ -292,13 +293,23 @@ public class StorageCacheManagerImpl implements StorageCacheManager, Manager {
s_logger.debug("there is already one in the cache store"); s_logger.debug("there is already one in the cache store");
DataObject dataObj = objectInStoreMgr.get(data, store); DataObject dataObj = objectInStoreMgr.get(data, store);
dataObj.incRefCount(); dataObj.incRefCount();
return dataObj; existingDataObj = dataObj;
} }
} }
if(existingDataObj == null) {
s_logger.debug("create " + typeName + " cache entry(id: " + dataId + ") on store(id: " + storeId + ")"); s_logger.debug("create " + typeName + " cache entry(id: " + dataId + ") on store(id: " + storeId + ")");
objOnCacheStore = store.create(data); objOnCacheStore = store.create(data);
} }
lock.notifyAll();
}
if (existingDataObj != null) {
return existingDataObj;
}
if (objOnCacheStore == null) {
s_logger.error("create " + typeName + " cache entry(id: " + dataId + ") on store(id: " + storeId + ") failed");
return null;
}
AsyncCallFuture<CopyCommandResult> future = new AsyncCallFuture<CopyCommandResult>(); AsyncCallFuture<CopyCommandResult> future = new AsyncCallFuture<CopyCommandResult>();
CopyCommandResult result = null; CopyCommandResult result = null;