Repository: cloudstack
Updated Branches:
  refs/heads/4.5 20ce346f3 -> e50547a3e


engine/storage/snapshot: Fix NPE when parent could be null

Fixed potential NPE in SnapshotServiceImpl where parent snapshot is null

Signed-off-by: Rohit Yadav <[email protected]>


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

Branch: refs/heads/4.5
Commit: e50547a3ea558f9ab6a1e396dd32b7a4149b32e1
Parents: 20ce346
Author: Rohit Yadav <[email protected]>
Authored: Mon Jun 29 18:33:22 2015 +0200
Committer: Rohit Yadav <[email protected]>
Committed: Mon Jun 29 18:33:22 2015 +0200

----------------------------------------------------------------------
 .../apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e50547a3/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
 
b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
index 5a8afc6..4c76cda 100644
--- 
a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
+++ 
b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
@@ -237,7 +237,10 @@ public class SnapshotServiceImpl implements 
SnapshotService {
             // Note that DataStore information in parentSnapshot is for primary
             // data store here, we need to
             // find the image store where the parent snapshot backup is located
-            SnapshotDataStoreVO parentSnapshotOnBackupStore = 
_snapshotStoreDao.findBySnapshot(parentSnapshot.getId(), DataStoreRole.Image);
+            SnapshotDataStoreVO parentSnapshotOnBackupStore = null;
+            if (parentSnapshot != null) {
+                parentSnapshotOnBackupStore = 
_snapshotStoreDao.findBySnapshot(parentSnapshot.getId(), DataStoreRole.Image);
+            }
             if (parentSnapshotOnBackupStore == null) {
                 return dataStoreMgr.getImageStore(snapshot.getDataCenterId());
             }

Reply via email to