Juan Hernandez has uploaded a new change for review.

Change subject: restapi: Avoid NPE with empty app list
......................................................................

restapi: Avoid NPE with empty app list

Currently we don't check the list of applications installed in a VM to
make sure that the application names aren't empty. This patch fixes
that in order to prevent NPEs.

Change-Id: Ieed7a5b90732f510973bedd7306d236ade4b2b3a
Bug-Url: https://bugzilla.redhat.com/1092448
Signed-off-by: Juan Hernandez <juan.hernan...@redhat.com>
---
M 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmApplicationsResource.java
1 file changed, 6 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/92/27192/1

diff --git 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmApplicationsResource.java
 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmApplicationsResource.java
index 5621c35..458eb7e 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmApplicationsResource.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmApplicationsResource.java
@@ -22,10 +22,12 @@
     public Applications list() {
         VM vm = getEntity(entityType, VdcQueryType.GetVmByVmId, new 
IdQueryParameters(vmId), vmId.toString(), true);
         Applications applications = new Applications();
-        int index = 1;
-        if (vm.getAppList() != null) {
-            for (String appName : vm.getAppList().split(",")) {
-                applications.getApplications().add(addLinks(map(appName)));
+        String appList = vm.getAppList();
+        if (appList != null) {
+            for (String appName : appList.split(",")) {
+                if (!appName.isEmpty()) {
+                    applications.getApplications().add(addLinks(map(appName)));
+                }
             }
         }
         return applications;
@@ -40,10 +42,6 @@
         model.setVm(new org.ovirt.engine.api.model.VM());
         model.getVm().setId(vmId.toString());
         return model;
-    }
-
-    private String buildId(int index) {
-        return new Guid("0-0-0-0-"+index).toString();
     }
 
     @Override


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieed7a5b90732f510973bedd7306d236ade4b2b3a
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <juan.hernan...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to