in java/src/main/java/org/apache/brooklyn/rest/client/util/http/BuiltResponsePreservingError.java [47:68]
public static <T> Response copyResponseAndClose(Response source, Class<T> type) {
int status = -1;
Headers<Object> headers = new Headers<Object>();
Object entity = null;
try {
status = source.getStatus();
if (source instanceof org.jboss.resteasy.client.core.BaseClientResponse)
headers.putAll(((org.jboss.resteasy.client.core.BaseClientResponse<?>)source).getMetadata());
if (source instanceof org.jboss.resteasy.client.ClientResponse) {
entity = ((org.jboss.resteasy.client.ClientResponse<?>)source).getEntity(type);
} else {
entity = source.getEntity();
}
return new BuiltResponsePreservingError(status, headers, entity, new Annotation[0], null);
} catch (Exception e) {
Exceptions.propagateIfFatal(e);
return new BuiltResponsePreservingError(status, headers, entity, new Annotation[0], e);
} finally {
if (source instanceof org.jboss.resteasy.client.core.BaseClientResponse)
((org.jboss.resteasy.client.core.BaseClientResponse<?>)source).close();
}
}