Hello Shmuel Melamud,

I'd like you to do a code review.  Please visit

    https://gerrit.ovirt.org/40830

to review the following change.

Change subject: core: null checks in IconUtils
......................................................................

core: null checks in IconUtils

Added null checks to avoid NullPointerException when
vmBase.getLargeIconId() == null. This happens, for example, when
NEXT_RUN snapshot is applied as it doesn't contain icons.

Change-Id: I162f69ae2cd31d26bd8835b0a6f77926bb7b1bb4
Signed-off-by: Shmuel Melamud <smela...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/IconUtils.java
1 file changed, 8 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/30/40830/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/IconUtils.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/IconUtils.java
index da58fc5..767695f 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/IconUtils.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/IconUtils.java
@@ -128,16 +128,22 @@
             }
         }
         List<Guid> unusedIconIds = new ArrayList<>(2);
-        if 
(!newVmBase.getSmallIconId().equals(originalVmBase.getSmallIconId())) {
+        if (newVmBase.getSmallIconId() != null && 
originalVmBase.getSmallIconId() != null &&
+                
!newVmBase.getSmallIconId().equals(originalVmBase.getSmallIconId())) {
             unusedIconIds.add(originalVmBase.getSmallIconId());
         }
-        if 
(!newVmBase.getLargeIconId().equals(originalVmBase.getLargeIconId())) {
+        if (newVmBase.getLargeIconId() != null && 
originalVmBase.getLargeIconId() != null &&
+                
!newVmBase.getLargeIconId().equals(originalVmBase.getLargeIconId())) {
             unusedIconIds.add(originalVmBase.getLargeIconId());
         }
         return unusedIconIds;
     }
 
     private static void computeSmallByLargeIconId(VmBase vmBase) {
+        if (vmBase.getLargeIconId() == null) {
+            return;
+        }
+
         final List<VmIconDefault> iconDefaultsByLargeIconId = 
DbFacade.getInstance().getVmIconsDefaultDao()
                 .getByLargeIconId(vmBase.getLargeIconId());
         if (!iconDefaultsByLargeIconId.isEmpty()) {


-- 
To view, visit https://gerrit.ovirt.org/40830
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I162f69ae2cd31d26bd8835b0a6f77926bb7b1bb4
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Shmuel Leib Melamud <smela...@redhat.com>
Gerrit-Reviewer: Shmuel Melamud <smela...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to