CLOUDSTACK-6011 . When detach is called on a deleted volume, avoid the NPE and throw an appropriate exception instead

This commit is contained in:
Likitha Shetty 2014-02-03 17:59:58 +05:30
parent 9cb37ec349
commit f4a96d4c85
1 changed files with 5 additions and 5 deletions

View File

@ -1382,6 +1382,11 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
volume = _volsDao.findByInstanceAndDeviceId(cmmd.getVirtualMachineId(), cmmd.getDeviceId()).get(0);
}
// Check that the volume ID is valid
if (volume == null) {
throw new InvalidParameterValueException("Unable to find volume with ID: " + volumeId);
}
Long vmId = null;
if (cmmd.getVirtualMachineId() == null) {
@ -1390,11 +1395,6 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
vmId = cmmd.getVirtualMachineId();
}
// Check that the volume ID is valid
if (volume == null) {
throw new InvalidParameterValueException("Unable to find volume with ID: " + volumeId);
}
// Permissions check
_accountMgr.checkAccess(caller, null, true, volume);