Martin Betak has uploaded a new change for review. Change subject: backend: Fix NPE in UpdateVmCommand ......................................................................
backend: Fix NPE in UpdateVmCommand When updating the VM via REST-api, the isSoundDeviceEnabled field of command parameters can be null which caused NPE when trying to convert to primitive boolean in invocation of checkPciAndIdeLimit method. Now in case of null value for said parameter, we determine the current status of sound device by querying the DB and pass not-null value to checkPciAndIdeLimit. Change-Id: Ic794bc7f4550e59daf21b013ec9c15237ee4af19 Signed-off-by: Martin Betak <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java 1 file changed, 7 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/61/23361/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java index e77ae9a..a1960db 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java @@ -406,6 +406,12 @@ List<Disk> allDisks = getDbFacade().getDiskDao().getAllForVm(getVmId()); List<VmNic> interfaces = getVmNicDao().getAllForVm(getVmId()); + Boolean isSoundDeviceEnabled = getParameters().isSoundDeviceEnabled(); + if (isSoundDeviceEnabled == null) { + List<VmDevice> soundDevices = getDbFacade().getVmDeviceDao().getVmDeviceByVmIdAndType(getVmId(), VmDeviceGeneralType.SOUND); + isSoundDeviceEnabled = soundDevices.size() != 0; + } + return checkPciAndIdeLimit( vmFromParams.getOs(), getVdsGroup().getcompatibility_version(), @@ -415,7 +421,7 @@ isVirtioScsiEnabled(), hasWatchdog(), getParameters().isBalloonEnabled(), - getParameters().isSoundDeviceEnabled(), + isSoundDeviceEnabled, getReturnValue().getCanDoActionMessages()); } -- To view, visit http://gerrit.ovirt.org/23361 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic794bc7f4550e59daf21b013ec9c15237ee4af19 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Martin Betak <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
