From d0c8102a6750eae0fa290f14d4505c254e8f097d Mon Sep 17 00:00:00 2001 From: rfeng Date: Mon, 1 Oct 2012 05:09:58 +0000 Subject: Fix the entity consumption git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1392211 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/binding/rest/provider/RESTBindingInvoker.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'sca-java-2.x/trunk') diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java index b6c7312edc..2ec467a61f 100644 --- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java +++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java @@ -55,7 +55,7 @@ import javax.ws.rs.core.MediaType; 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 class RESTBindingInvoker implements Invoker { } 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; -- cgit v1.2.3