This is an automated email from the ASF dual-hosted git repository.
heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-client.git
The following commit(s) were added to refs/heads/master by this push:
new cf64d86 fix to accommodate change in type of response builder
cf64d86 is described below
commit cf64d86c68b1518e9b790346a903649536c0b935
Author: Alex Heneveld <[email protected]>
AuthorDate: Fri Aug 6 20:50:18 2021 +0100
fix to accommodate change in type of response builder
---
.../org/apache/brooklyn/rest/client/BrooklynApi.java | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git
a/java/src/main/java/org/apache/brooklyn/rest/client/BrooklynApi.java
b/java/src/main/java/org/apache/brooklyn/rest/client/BrooklynApi.java
index 2173e4e..896350a 100644
--- a/java/src/main/java/org/apache/brooklyn/rest/client/BrooklynApi.java
+++ b/java/src/main/java/org/apache/brooklyn/rest/client/BrooklynApi.java
@@ -51,6 +51,7 @@ import org.apache.brooklyn.util.collections.MutableMap;
import org.apache.brooklyn.util.exceptions.Exceptions;
import org.apache.brooklyn.util.javalang.AggregateClassLoader;
import org.apache.brooklyn.util.net.Urls;
+import org.apache.cxf.jaxrs.impl.ResponseImpl;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.Credentials;
import org.apache.http.auth.UsernamePasswordCredentials;
@@ -348,13 +349,16 @@ public class BrooklynApi {
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);
- }
}
+
+ Object entity = response.getEntity();
+
+ // Handle JSON BuiltResponsePreservingError turning objects into
Strings
+ if (entity instanceof String && !type.isAssignableFrom(String.class)) {
+ failSomeErrors(response, type, true);
+ return new Gson().fromJson(response.getEntity().toString(), type);
+ }
+
// Last-gasp attempt.
return type.cast(response.getEntity());
}