Arik Hadas has uploaded a new change for review. Change subject: engine: fix NPE when trying to export not existing template ......................................................................
engine: fix NPE when trying to export not existing template The fix is all about checking whether the template exists before trying to get its storage pool id. This patch contains two other changes: 1. the description of the command moved from #canDoAction to the constructor which is a more appropriate place to initialize things. 2. add a check that the template exists as the first thing that is checked in #canDoAction(). this check is already made at MoveOrCopyTemplateCommand#canDoAction but it is taking place too late - we should address this issue but in a different patch in order to keep this one simple fix. Change-Id: I757672ec2f989f4dc1bc5403878c5cbee69f9cf0 Bug-Url: https://bugzilla.redhat.com/928365 Signed-off-by: Arik Hadas <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ExportVmTemplateCommand.java 1 file changed, 6 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/62/13662/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ExportVmTemplateCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ExportVmTemplateCommand.java index 379c247..95dfe36 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ExportVmTemplateCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ExportVmTemplateCommand.java @@ -33,7 +33,10 @@ public ExportVmTemplateCommand(T parameters) { super(parameters); - setStoragePoolId(getVmTemplate().getstorage_pool_id()); + if (getVmTemplate() != null) { + setDescription(getVmTemplateName()); + setStoragePoolId(getVmTemplate().getstorage_pool_id()); + } } protected ExportVmTemplateCommand(Guid commandId) { @@ -114,8 +117,8 @@ @Override protected boolean canDoAction() { - if (getVmTemplate() != null) { - setDescription(getVmTemplateName()); + if (getVmTemplate() == null) { + return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST); } StorageDomainValidator storageDomainValidator = new StorageDomainValidator(getStorageDomain()); boolean retVal = validate(storageDomainValidator.isDomainExistAndActive()); -- To view, visit http://gerrit.ovirt.org/13662 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I757672ec2f989f4dc1bc5403878c5cbee69f9cf0 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Arik Hadas <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
