ApiResponseHelper: fix NPE when parent of snapshot is null

This commit is contained in:
Rohit Yadav 2015-02-05 17:02:30 +05:30
parent ca0a77088c
commit 1cf165f86d
1 changed files with 4 additions and 1 deletions

View File

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