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

    https://github.com/apache/brooklyn-client/pull/40#discussion_r115434780
  
    --- Diff: 
java/src/main/java/org/apache/brooklyn/rest/client/BrooklynApi.java ---
    @@ -375,34 +376,112 @@ public AccessApi getAccessApi() {
             return proxy(AccessApi.class);
         }
     
    +    /** Extracts an instance of the given type from the response, 
including JSON strings in there.
    +     * Forgives most errors except for obviously incompatible ones.
    +     * To fail on any server error, use {@link 
#getEntityOnSuccess(Response, Class)}.
    +     * <p>
    +     * This method will coerce and empty map "{}" to a no-arg contructed 
instance of the target class.
    +     * This method will also ignore most errors in the response. 
    +     * <p>
    +     * It has changed to identify the most obvious errors. */
         public static <T> T getEntity(Response response, Class<T> type) {
             if (response instanceof ClientResponse) {
                 ClientResponse<?> clientResponse = (ClientResponse<?>) 
response;
                 return clientResponse.getEntity(type);
             } else if (response instanceof BuiltResponse) {
                 // Handle BuiltResponsePreservingError turning objects into 
Strings
                 if (response.getEntity() instanceof String && 
!type.equals(String.class)) {
    +                failSomeErrors(response, type, true);
                     return new 
Gson().fromJson(response.getEntity().toString(), type);
                 }
             }
             // Last-gasp attempt.
             return type.cast(response.getEntity());
         }
    +    
    +    /** As {@link #getEntity(Response, Class)} but fails if the response 
is an error of any sort. */
    +    public static <T> T getEntityOnSuccess(Response response, Class<T> 
type) {
    +        failSomeErrors(response, type, false);
    +        return getEntity(response, type);
    +    }
     
    +    /** This fails if it is clearly an ApiError response which the caller 
did not want.
    +     * To fail on any error (probably better), use  */
    --- End diff --
    
    Missing text in comment - use what?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to