ApiResponseHelper: fix NPE when parent of snapshot is null

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2015-02-05 17:02:30 +05:30
parent 7c41a1184c
commit fae4fdae53
1 changed files with 4 additions and 2 deletions

View File

@ -548,8 +548,10 @@ public class ApiResponseHelper implements ResponseGenerator {
}
if (vmSnapshot.getParent() != null) {
VMSnapshot vmSnapshotParent = ApiDBUtils.getVMSnapshotById(vmSnapshot.getParent());
vmSnapshotResponse.setParent(vmSnapshotParent.getUuid());
vmSnapshotResponse.setParentName(vmSnapshotParent.getDisplayName());
if (vmSnapshotParent != null) {
vmSnapshotResponse.setParent(vmSnapshotParent.getUuid());
vmSnapshotResponse.setParentName(vmSnapshotParent.getDisplayName());
}
}
vmSnapshotResponse.setCurrent(vmSnapshot.getCurrent());
vmSnapshotResponse.setType(vmSnapshot.getType().toString());