Juan Hernandez has uploaded a new change for review.

Change subject: restapi: Avoid NPE when receiving NUMA node without cores
......................................................................

restapi: Avoid NPE when receiving NUMA node without cores

Currently the server assumes the presence of the "cores" element when
receiving a request to add a NUMA node and if they aren't present a NPE
is generated. To avoid this issue this patch modifies the server so that
it checks for the presence of this element.

Change-Id: I12bbdd066af9818dcb2ffad5df8ac3849e3efdd6
Signed-off-by: Juan Hernandez <[email protected]>
---
M 
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/NumaMapper.java
1 file changed, 11 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/39/42039/1

diff --git 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/NumaMapper.java
 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/NumaMapper.java
index 2953d63..cdb8646 100644
--- 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/NumaMapper.java
+++ 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/NumaMapper.java
@@ -92,10 +92,17 @@
         if (model.isSetIndex()) {
             entity.setIndex(model.getIndex());
         }
-        if (model.isSetCpu()) {
-            List<Integer> ids = new ArrayList<Integer>();
-            for (Core core : model.getCpu().getCores().getCore()) {
-                ids.add(core.getIndex());
+        CPU cpu = model.getCpu();
+        if (cpu != null) {
+            List<Integer> ids = new ArrayList<>();
+            Cores cores = cpu.getCores();
+            if (cores != null) {
+                for (Core core : cores.getCore()) {
+                    Integer index = core.getIndex();
+                    if (index != null) {
+                        ids.add(index);
+                    }
+                }
             }
             entity.setCpuIds(ids);
         }


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I12bbdd066af9818dcb2ffad5df8ac3849e3efdd6
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to