Repository: incubator-brooklyn Updated Branches: refs/heads/master da6d887f9 -> b3bdacb64
BROOKLYN-154: Don't call methods that might not be there This code attempted to call non-standard extensions on the javax.ws.rs.core.Response class. This change does the appropriate instanceof checks to ensure that no non-standard methods are called if we have a plain old Response object. Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/94b031e2 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/94b031e2 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/94b031e2 Branch: refs/heads/master Commit: 94b031e24d9f9984ea79840d2249964090b991e3 Parents: ea1d6cb Author: Richard Downer <[email protected]> Authored: Wed Jul 1 12:43:05 2015 +0100 Committer: Richard Downer <[email protected]> Committed: Thu Jul 2 02:28:11 2015 +0100 ---------------------------------------------------------------------- .../java/brooklyn/util/http/BuiltResponsePreservingError.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/94b031e2/usage/rest-client/src/main/java/brooklyn/util/http/BuiltResponsePreservingError.java ---------------------------------------------------------------------- diff --git a/usage/rest-client/src/main/java/brooklyn/util/http/BuiltResponsePreservingError.java b/usage/rest-client/src/main/java/brooklyn/util/http/BuiltResponsePreservingError.java index c3ad96a..3bd88e6 100644 --- a/usage/rest-client/src/main/java/brooklyn/util/http/BuiltResponsePreservingError.java +++ b/usage/rest-client/src/main/java/brooklyn/util/http/BuiltResponsePreservingError.java @@ -22,6 +22,7 @@ import java.lang.annotation.Annotation; import javax.ws.rs.core.Response; +import org.jboss.resteasy.client.core.BaseClientResponse; import org.jboss.resteasy.core.Headers; import org.jboss.resteasy.specimpl.BuiltResponse; @@ -51,7 +52,8 @@ public class BuiltResponsePreservingError extends BuiltResponse { Object entity = null; try { status = source.getStatus(); - headers.putAll(source.getHeaders()); + if (source instanceof BaseClientResponse) + headers.putAll(((BaseClientResponse<?>)source).getMetadata()); if (source instanceof org.jboss.resteasy.client.ClientResponse) { entity = ((org.jboss.resteasy.client.ClientResponse<?>)source).getEntity(type); } else { @@ -62,7 +64,8 @@ public class BuiltResponsePreservingError extends BuiltResponse { Exceptions.propagateIfFatal(e); return new BuiltResponsePreservingError(status, headers, entity, new Annotation[0], e); } finally { - source.close(); + if (source instanceof BaseClientResponse) + ((BaseClientResponse<?>)source).close(); } }
