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
(cherry picked from commit f4a96d4c85)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
d9e94717b5
commit
e2fd4ef42c
|
|
@ -1387,6 +1387,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) {
|
||||
|
|
@ -1395,11 +1400,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