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: I99dd3fe2aae38508adcd739cdd6cc3f75a167f79
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, 16 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/41/16041/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..84e8edb 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,19 @@
         return new Guid();
     }
 
-    public static boolean isWindowsOsType(int osType) {
+    public static boolean isWindowsOsType(Integer osType) {
+        if (osType == null) {
+            return false;
+        }
+
         return windowsOsIds.contains(osType);
     }
 
-    public static boolean isLinuxOsType(int osId) {
+    public static boolean isLinuxOsType(Integer osId) {
+        if (osId == null) {
+            return false;
+        }
+
         return linuxOsIds.contains(osId);
     }
 
@@ -2987,7 +2995,11 @@
         });
     }
 
-    public static String getOsName(int osId) {
+    public static String getOsName(Integer osId) {
+        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..c94c747 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,7 @@
     }
 
     public TimeZoneType getTimeZoneType() {
-        int vmOsType = (Integer) getModel().getOSType().getSelectedItem();
+        Integer vmOsType = (Integer) getModel().getOSType().getSelectedItem();
         return AsyncDataProvider.isWindowsOsType(vmOsType) ? 
TimeZoneType.WINDOWS_TIMEZONE
                 : TimeZoneType.GENERAL_TIMEZONE;
     }


-- 
To view, visit http://gerrit.ovirt.org/16041
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I99dd3fe2aae38508adcd739cdd6cc3f75a167f79
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

Reply via email to