CLOUDSTACK-8164: Look for all host to avoid NPE

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Abhinandan Prateek 2015-01-19 11:29:22 +05:30 committed by Rohit Yadav
parent fd0eb6c29e
commit a1a601be5a
2 changed files with 3 additions and 1 deletions

View File

@ -82,7 +82,7 @@ public class VMSnapshotHelperImpl implements VMSnapshotHelper {
// check if lastHostId is available
if (vm.getLastHostId() != null) {
HostVO lastHost = hostDao.findById(vm.getLastHostId());
HostVO lastHost = hostDao.findByIdIncludingRemoved(vm.getLastHostId());
if (lastHost.getStatus() == com.cloud.host.Status.Up && !lastHost.isInMaintenanceStates())
return lastHost.getId();
}

View File

@ -748,6 +748,8 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
if (jobResult != null) {
if (jobResult instanceof ConcurrentOperationException)
throw (ConcurrentOperationException)jobResult;
else if (jobResult instanceof InvalidParameterValueException)
throw (InvalidParameterValueException)jobResult;
else if (jobResult instanceof Throwable)
throw new RuntimeException("Unexpected exception", (Throwable)jobResult);
}