You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2015/06/19 15:39:48 UTC
[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 <ro...@gmail.com>
Authored: Fri Jun 19 10:18:13 2015 +0100
Committer: Robert Moss <ro...@gmail.com>
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;
}