Tomas Jelinek has uploaded a new change for review. Change subject: frontend: Fixed NPE on new pool dialog ......................................................................
frontend: Fixed NPE on new pool dialog The 282f87b3b0a96008d87cad21cc48e4d8adcd4cf9 did bring a regression that the new pool throws an NPE. The problem was in the fact, that on some places the osId was taken from the getSelectedItem() and directly converted to int - but there are cases where it can be null and that throws an NPE. Null it can be for example when UnitVmModel.initOSType() sets getOSType().setItems(AsyncDataProvider.getOsIds()), which results in ListModel.itemsChanged() which does setSelectedItems(null); and just after than it sets the given items. Change-Id: If6eb8db7e59204a6a77fbd802fcf7a378c31388b Signed-off-by: Tomas Jelinek <[email protected]> --- M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java 2 files changed, 20 insertions(+), 4 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/62/16062/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java index 75af146..d34db59 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java @@ -2920,11 +2920,21 @@ return new Guid(); } - public static boolean isWindowsOsType(int osType) { + public static boolean isWindowsOsType(Integer osType) { + // can be null as a consequence of setItems on ListModel + if (osType == null) { + return false; + } + return windowsOsIds.contains(osType); } - public static boolean isLinuxOsType(int osId) { + public static boolean isLinuxOsType(Integer osId) { + // can be null as a consequence of setItems on ListModel + if (osId == null) { + return false; + } + return linuxOsIds.contains(osId); } @@ -2987,7 +2997,12 @@ }); } - public static String getOsName(int osId) { + public static String getOsName(Integer osId) { + // can be null as a consequence of setItems on ListModel + if (osId == null) { + return ""; + } + return osNames.get(osId); } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java index 06147c9..09d4240 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java @@ -203,7 +203,8 @@ } public TimeZoneType getTimeZoneType() { - int vmOsType = (Integer) getModel().getOSType().getSelectedItem(); + // can be null as a consequence of setItems on ListModel + Integer vmOsType = (Integer) getModel().getOSType().getSelectedItem(); return AsyncDataProvider.isWindowsOsType(vmOsType) ? TimeZoneType.WINDOWS_TIMEZONE : TimeZoneType.GENERAL_TIMEZONE; } -- To view, visit http://gerrit.ovirt.org/16062 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If6eb8db7e59204a6a77fbd802fcf7a378c31388b Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Tomas Jelinek <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
