Return-Path: X-Original-To: apmail-brooklyn-commits-archive@minotaur.apache.org Delivered-To: apmail-brooklyn-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 47C2618083 for ; Fri, 19 Jun 2015 13:39:47 +0000 (UTC) Received: (qmail 1073 invoked by uid 500); 19 Jun 2015 13:39:47 -0000 Delivered-To: apmail-brooklyn-commits-archive@brooklyn.apache.org Received: (qmail 1051 invoked by uid 500); 19 Jun 2015 13:39:47 -0000 Mailing-List: contact commits-help@brooklyn.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.incubator.apache.org Delivered-To: mailing list commits@brooklyn.incubator.apache.org Received: (qmail 1042 invoked by uid 99); 19 Jun 2015 13:39:47 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Jun 2015 13:39:47 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id BAAB0CF01F for ; Fri, 19 Jun 2015 13:39:46 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.445 X-Spam-Level: * X-Spam-Status: No, score=1.445 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.335] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id bcoQmHQ9F10C for ; Fri, 19 Jun 2015 13:39:46 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with SMTP id EA5DE27650 for ; Fri, 19 Jun 2015 13:39:45 +0000 (UTC) Received: (qmail 1033 invoked by uid 99); 19 Jun 2015 13:39:45 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Jun 2015 13:39:45 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 653CFE35D4; Fri, 19 Jun 2015 13:39:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: heneveld@apache.org To: commits@brooklyn.incubator.apache.org Date: Fri, 19 Jun 2015 13:39:48 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [4/6] incubator-brooklyn git commit: add log and propogate exception if fatal add log and propogate exception if fatal Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/aa5dc0d2 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/aa5dc0d2 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/aa5dc0d2 Branch: refs/heads/master Commit: aa5dc0d2ad751ef24696c627b88954d088bc63d0 Parents: 1e2887d Author: Robert Moss Authored: Fri Jun 19 10:18:13 2015 +0100 Committer: Robert Moss Committed: Fri Jun 19 10:18:13 2015 +0100 ---------------------------------------------------------------------- .../src/main/java/brooklyn/rest/client/BrooklynApi.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/aa5dc0d2/usage/rest-client/src/main/java/brooklyn/rest/client/BrooklynApi.java ---------------------------------------------------------------------- diff --git a/usage/rest-client/src/main/java/brooklyn/rest/client/BrooklynApi.java b/usage/rest-client/src/main/java/brooklyn/rest/client/BrooklynApi.java index f8d9dfb..cabdcd2 100644 --- a/usage/rest-client/src/main/java/brooklyn/rest/client/BrooklynApi.java +++ b/usage/rest-client/src/main/java/brooklyn/rest/client/BrooklynApi.java @@ -34,6 +34,7 @@ import org.apache.http.auth.AuthScope; import org.apache.http.auth.Credentials; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.impl.client.DefaultHttpClient; +import org.eclipse.jetty.util.log.Log; import org.jboss.resteasy.client.ClientExecutor; import org.jboss.resteasy.client.ClientRequest; import org.jboss.resteasy.client.ClientResponse; @@ -41,6 +42,8 @@ import org.jboss.resteasy.client.ProxyFactory; import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor; import org.jboss.resteasy.specimpl.BuiltResponse; import org.jboss.resteasy.util.GenericType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import brooklyn.rest.api.AccessApi; import brooklyn.rest.api.ActivityApi; @@ -71,6 +74,7 @@ public class BrooklynApi { private final String target; private final ClientExecutor clientExecutor; + private static final Logger LOG = LoggerFactory.getLogger(BrooklynApi.class); public BrooklynApi(URL endpoint) { this(checkNotNull(endpoint, "endpoint").toString()); @@ -127,7 +131,7 @@ public class BrooklynApi { if (result1 instanceof Response) { Response resp = (Response)result1; if(HttpTool.isStatusCodeHealthy(resp.getStatus()) && method.isAnnotationPresent(ApiOperation.class)) { - type = getClassFromMethodAnnotationOrDefault(resp, method, type); + type = getClassFromMethodAnnotationOrDefault(method, type); } // wrap the original response so it self-closes result1 = BuiltResponsePreservingError.copyResponseAndClose(resp, type); @@ -142,13 +146,15 @@ public class BrooklynApi { } } - private Class getClassFromMethodAnnotationOrDefault(Response resp, Method method, Class def){ + private Class getClassFromMethodAnnotationOrDefault(Method method, Class def){ Class type; try{ String responseClass = method.getAnnotation(ApiOperation.class).responseClass(); type = Class.forName(responseClass); } catch (Exception e) { type = def; + LOG.info("Unable to get class from annotation: {}. Defaulting to {}", e.getMessage(), def.getName()); + Exceptions.propagateIfFatal(e); } return type; }