Daniel Erez has uploaded a new change for review.

Change subject: restapi: a potential NPE when a user invokes actions
......................................................................

restapi: a potential NPE when a user invokes actions

When a user invokes an action without sending filter=true property,
the action may throw a NPE on command creation flow.

The underlining issue is in AbstractBackendCollectionResource
-> resolveCreated method. If an exception is thrown (e.g. due to
lack of permissions to execute query), the method returns null.

Instead of tolerating the exception, call handleError method
(to output a proper error message).

Change-Id: I55f5ae906d6c0d2023783e7b61abe3bf9d01f28f
Bug-Url: https://bugzilla.redhat.com/915106
Signed-off-by: Daniel Erez <de...@redhat.com>
---
M 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/AbstractBackendCollectionResource.java
1 file changed, 2 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/94/15394/1

diff --git 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/AbstractBackendCollectionResource.java
 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/AbstractBackendCollectionResource.java
index fa25b99..d2ea319 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/AbstractBackendCollectionResource.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/AbstractBackendCollectionResource.java
@@ -150,11 +150,8 @@
         try {
             return entityResolver.resolve((T) result.getActionReturnValue());
         } catch (Exception e) {
-            // we tolerate a failure in the entity resolution
-            // as the substantive action (entity creation) has
-            // already succeeded
-            e.printStackTrace();
-            return null;
+            // Handling exception as we can't tolerate the failure
+            return handleError(e, false);
         }
     }
     protected String asString(VdcReturnValueBase result) {


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I55f5ae906d6c0d2023783e7b61abe3bf9d01f28f
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Daniel Erez <de...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to