aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authormark.j.leonard <mark.j.leonard@gmail.com>2017-07-11 12:02:13 +0100
committermark.j.leonard <mark.j.leonard@gmail.com>2017-07-11 15:24:58 +0100
commitda669cac0eb4e1832082ffb91cf24f998c114dee (patch)
treed6de32c35276dc2b3d46814e63e5ade64b15aba2 /src/main/java
parentcf2f6ef5fadb27bab1e65cb25ff9d36acad4a68d (diff)
Fix incorrect result for a server response of 204
The Rest Client will not always call the method getEntity() on a com.sun.jersey.api.client.ClientResponse object, which is documented to throw a UniformInterfaceException if the HTTP server response status is 204 (No Content). This fix prevents the Rest Client handling the thrown exception by returning a 500 response to the caller, which would wrongly indicate an Internal Server Error. Change-Id: I7b78d2b43213e330593bbea559025f790db6264f Issue-ID: AAI-48 Signed-off-by: mark.j.leonard <mark.j.leonard@gmail.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/openecomp/restclient/client/RestClient.java10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/main/java/org/openecomp/restclient/client/RestClient.java b/src/main/java/org/openecomp/restclient/client/RestClient.java
index 02d19e6..7dbc373 100644
--- a/src/main/java/org/openecomp/restclient/client/RestClient.java
+++ b/src/main/java/org/openecomp/restclient/client/RestClient.java
@@ -719,16 +719,16 @@ public class RestClient {
opResult.setFailureCause("Client response was null");
return;
}
-
+
int statusCode = response.getStatus();
- String payload = response.getEntity(String.class);
-
opResult.setResultCode(statusCode);
if (opResult.wasSuccessful()) {
- opResult.setResult(payload);
+ if (statusCode != Response.Status.NO_CONTENT.getStatusCode()) {
+ opResult.setResult(response.getEntity(String.class));
+ }
} else {
- opResult.setFailureCause(payload);
+ opResult.setFailureCause(response.getEntity(String.class));
}
opResult.setHeaders(response.getHeaders());