Skip to content

Commit 969bbb0

Browse files
abhinandanprateekyadvr
authored andcommitted
CLOUDSTACK-8164: Look for all host to avoid NPE
(cherry picked from commit d8def3d) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> Conflicts: engine/storage/src/org/apache/cloudstack/storage/helper/VMSnapshotHelperImpl.java
1 parent 2c7cacd commit 969bbb0

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎engine/storage/src/org/apache/cloudstack/storage/helper/VMSnapshotHelperImpl.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ public Long pickRunningHost(Long vmId) {
7979
return vm.getHostId();
8080

8181
// check if lastHostId is available
82-
if(vm.getLastHostId() != null){
83-
HostVO lastHost = hostDao.findById(vm.getLastHostId());
84-
if(lastHost.getStatus() == com.cloud.host.Status.Up && !lastHost.isInMaintenanceStates())
82+
if (vm.getLastHostId() != null) {
83+
HostVO lastHost = hostDao.findByIdIncludingRemoved(vm.getLastHostId());
84+
if (lastHost.getStatus() == com.cloud.host.Status.Up && !lastHost.isInMaintenanceStates())
8585
return lastHost.getId();
8686
}
8787

‎server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,8 @@ public boolean deleteAllVMSnapshots(long vmId, VMSnapshot.Type type) {
766766
if (jobResult != null) {
767767
if (jobResult instanceof ConcurrentOperationException)
768768
throw (ConcurrentOperationException)jobResult;
769+
else if (jobResult instanceof InvalidParameterValueException)
770+
throw (InvalidParameterValueException)jobResult;
769771
else if (jobResult instanceof Throwable)
770772
throw new RuntimeException("Unexpected exception", (Throwable)jobResult);
771773
}

0 commit comments

Comments
 (0)