cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [2/3] git commit: updated refs/heads/master to 0c72f77
Date Fri, 17 Jul 2015 10:42:25 GMT
CLOUDSTACK-7539: no return in synchronised block

Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c3d28e1b
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c3d28e1b
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c3d28e1b

Branch: refs/heads/master
Commit: c3d28e1b96163b62c9f56931eef3f1dc0a4784a4
Parents: 780816e
Author: Daan Hoogland <daan@onecht.net>
Authored: Fri Jul 17 11:07:57 2015 +0200
Committer: Daan Hoogland <daan@onecht.net>
Committed: Fri Jul 17 11:07:57 2015 +0200

----------------------------------------------------------------------
 .../cache/manager/StorageCacheManagerImpl.java   | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c3d28e1b/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java
b/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java
index 6be3581..48e8af6 100644
--- a/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java
+++ b/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java
@@ -223,7 +223,7 @@ public class StorageCacheManagerImpl implements StorageCacheManager, Manager
{
 
     @Override
     public DataObject createCacheObject(DataObject data, DataStore store) {
-        DataObject objOnCacheStore;
+        DataObject objOnCacheStore = null;
         final Object lock;
         final DataObjectType type = data.getType();
         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 + ")");
 
+        DataObject existingDataObj = null;
         synchronized (lock) {
             DataObjectInStore obj = objectInStoreMgr.findObject(data, store);
             if (obj != null) {
@@ -292,12 +293,22 @@ public class StorageCacheManagerImpl implements StorageCacheManager,
Manager {
                     s_logger.debug("there is already one in the cache store");
                     DataObject dataObj = objectInStoreMgr.get(data, store);
                     dataObj.incRefCount();
-                    return dataObj;
+                    existingDataObj = dataObj;
                 }
             }
 
-            s_logger.debug("create " + typeName + " cache entry(id: " + dataId + ") on store(id:
" + storeId + ")");
-            objOnCacheStore = store.create(data);
+            if(existingDataObj == null) {
+                s_logger.debug("create " + typeName + " cache entry(id: " + dataId + ") on
store(id: " + storeId + ")");
+                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>();


Mime
View raw message