Permalink
Browse files

Fix the entity consumption

git-svn-id: https://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk@1392211 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 5a42a3b commit b7c81b00e805920dbc0c146d3ab635cf9b07c4b3 @raymondfeng raymondfeng committed Oct 1, 2012
@@ -55,7 +55,7 @@
import javax.ws.rs.core.UriBuilder;
import org.apache.http.client.HttpClient;
-import org.apache.http.entity.StringEntity;
+import org.apache.http.entity.ByteArrayEntity;
import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.assembly.WireFormat;
import org.apache.tuscany.sca.binding.rest.RESTBinding;
@@ -284,14 +284,9 @@ public Message invoke(Message msg) {
} catch (ClientWebException e) {
ClientResponse clientResponse = e.getResponse();
// Consume the entity
- String error = clientResponse.getEntity(String.class);
- StringEntity stringEntity;
- try {
- stringEntity = error == null ? null : new StringEntity(error);
- clientResponse.setEntity(stringEntity);
- } catch (UnsupportedEncodingException e1) {
- // Ignore
- }
+ byte[] error = clientResponse.getEntity(byte[].class);
+ ByteArrayEntity errorEntity = error == null ? null : new ByteArrayEntity(error);
+ clientResponse.setEntity(errorEntity);
throw e;
}
return msg;

0 comments on commit b7c81b0

Please sign in to comment.