Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/821#discussion_r142123410
  
    --- Diff: 
rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/BrooklynRestResourceUtils.java
 ---
    @@ -130,6 +143,36 @@ public Policy getPolicy(Entity entity, String policy) {
             
             throw WebResourceUtils.notFound("Cannot find policy '%s' in entity 
'%s'", policy, entity);
         }
    +    
    +    /** finds the policy indicated by the given ID or name.
    +     * @see {@link #getAdjunct(String,String,String)}.
    +     * <p>
    +     * 
    +     * @throws 404 or 412 (unless input is null in which case output is 
null) */
    +    public EntityAdjunct getAdjunct(Entity entity, String adjunct) {
    +        if (adjunct==null) return null;
    --- End diff --
    
    Feels wrong to return null if the `adjunct` param is null. 
    Looking at the uses of it, that results in a subsequent NPE (i.e. a 500 
response code).
    I'd change this method to return an appropriate 4xx response code (not sure 
which one - writing this offline!)
        
    I know that in this PR you've just followed the same convention as for 
`getPolicy()`, `getEntity()`, etc. But I think they are wrong as well! Happy 
for us to do that in a different PR.


---

Reply via email to