mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-6011 . When detach is called on a deleted volume, avoid the NPE and throw an appropriate exception instead
This commit is contained in:
parent
9cb37ec349
commit
f4a96d4c85
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue