Martin Mucha has posted comments on this change.

Change subject: restapi: fix NPE on ReloadConfigurationsCommand
......................................................................


Patch Set 3:

(1 comment)

http://gerrit.ovirt.org/#/c/34649/3/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/utils/LinkHelper.java
File 
backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/utils/LinkHelper.java:

Line 709:      * @return                     the #Collection instance 
representing the object's collection
Line 710:      */
Line 711:     private static Collection getCollection(BaseResource model, 
Class<? extends BaseResource> suggestedParentType) {
Line 712:         ParentToCollectionMap collections = 
TYPES.get(model.getClass());
Line 713: 
> returning null here will just introduce the NPE in other location of in the
I looked it up, and I think there's currently no such place. There's some 
spaghetti surrounding, but I think that by some luck NPE won't be generated. 
But even if that's true, it's still wrong, you're right. 

I think there should be proper definition, which model does not have 
subresources and fail for others, when they're not in TYPES map.

Problematic model is API for which there's no record in omnipotent TYPES map. 
At least, for this model, code must not fail. Current 'solution' should just 
silently return empty collection for misbehaving model. Maybe we can create 
list of model, which does not have collection (whatever it is) and for which 
null should be returned from this method.
Line 714:         if (collections == null) {
Line 715:             return null;
Line 716:         }
Line 717: 


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I70fd6b084a33bc7770de245c0001d3eefbb58b66
Gerrit-PatchSet: 3
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Martin Mucha <[email protected]>
Gerrit-Reviewer: Juan Hernandez <[email protected]>
Gerrit-Reviewer: Martin Mucha <[email protected]>
Gerrit-Reviewer: Moti Asayag <[email protected]>
Gerrit-Reviewer: [email protected]
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to