CID-1241966 Fix potential null deref

This commit is contained in:
Hugo Trippaers 2014-09-30 11:27:51 +02:00
parent ef4b5d41b7
commit 1c94017ff6
1 changed files with 33 additions and 33 deletions

View File

@ -211,16 +211,16 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
public VolumeVO allocateDuplicateVolumeVO(Volume oldVol, Long templateId) {
VolumeVO newVol = new VolumeVO(oldVol.getVolumeType(),
oldVol.getName(),
oldVol.getDataCenterId(),
oldVol.getDomainId(),
oldVol.getAccountId(),
oldVol.getDiskOfferingId(),
oldVol.getProvisioningType(),
oldVol.getSize(),
oldVol.getMinIops(),
oldVol.getMaxIops(),
oldVol.get_iScsiName());
oldVol.getName(),
oldVol.getDataCenterId(),
oldVol.getDomainId(),
oldVol.getAccountId(),
oldVol.getDiskOfferingId(),
oldVol.getProvisioningType(),
oldVol.getSize(),
oldVol.getMinIops(),
oldVol.getMaxIops(),
oldVol.get_iScsiName());
if (templateId != null) {
newVol.setTemplateId(templateId);
} else {
@ -595,16 +595,16 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
maxIops = maxIops != null ? maxIops : offering.getMaxIops();
VolumeVO vol = new VolumeVO(type,
name,
vm.getDataCenterId(),
owner.getDomainId(),
owner.getId(),
offering.getId(),
offering.getProvisioningType(),
size,
minIops,
maxIops,
null);
name,
vm.getDataCenterId(),
owner.getDomainId(),
owner.getId(),
offering.getId(),
offering.getProvisioningType(),
size,
minIops,
maxIops,
null);
if (vm != null) {
vol.setInstanceId(vm.getId());
}
@ -656,16 +656,16 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
maxIops = maxIops != null ? maxIops : offering.getMaxIops();
VolumeVO vol = new VolumeVO(type,
name,
vm.getDataCenterId(),
owner.getDomainId(),
owner.getId(),
offering.getId(),
offering.getProvisioningType(),
size,
minIops,
maxIops,
null);
name,
vm.getDataCenterId(),
owner.getDomainId(),
owner.getId(),
offering.getId(),
offering.getProvisioningType(),
size,
minIops,
maxIops,
null);
vol.setFormat(getSupportedImageFormatForCluster(template.getHypervisorType()));
if (vm != null) {
vol.setInstanceId(vm.getId());
@ -682,8 +682,8 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
}
if (vm.getType() == VirtualMachine.Type.User) {
UserVmVO userVm = _userVmDao.findById(vm.getId());
vol.setDisplayVolume(userVm.isDisplayVm());
UserVmVO userVm = _userVmDao.findById(vm.getId());
vol.setDisplayVolume(userVm.isDisplayVm());
}
@ -1092,7 +1092,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
if (assignedPool == null && recreate) {
assignedPool = _storagePoolDao.findById(vol.getPoolId());
}
if (assignedPool != null || recreate) {
if (assignedPool != null) {
Volume.State state = vol.getState();
if (state == Volume.State.Allocated || state == Volume.State.Creating) {
VolumeTask task = new VolumeTask(VolumeTaskType.RECREATE, vol, null);