From ee1e8a6c2a375a1a7232f2c7ca2f95f78b3c3d2f Mon Sep 17 00:00:00 2001 From: Daan Hoogland Date: Wed, 29 Jan 2014 12:36:34 +0100 Subject: [PATCH] findbugs: use system account id instead of null (security considerations to be made here) --- server/src/com/cloud/storage/VolumeApiServiceImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index 55582c6421d..c856379b812 100644 --- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java @@ -449,7 +449,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic volume.setPoolId(null); volume.setDataCenterId(zoneId); volume.setPodId(null); - volume.setAccountId((owner == null) ? null : owner.getAccountId()); + // to prevent a nullpointer deref I put the system account id here when no owner is given. + // TODO Decide if this is valid or whether throwing a CloudRuntimeException is more appropriate + volume.setAccountId((owner == null) ? Account.ACCOUNT_ID_SYSTEM : owner.getAccountId()); volume.setDomainId((owner == null) ? Domain.ROOT_DOMAIN : owner.getDomainId()); long diskOfferingId = _diskOfferingDao.findByUniqueName("Cloud.com-Custom").getId(); volume.setDiskOfferingId(diskOfferingId);