From c71524917eeecfa8aeb5c497d2c3660f0862ab71 Mon Sep 17 00:00:00 2001 From: rfeng Date: Wed, 8 Dec 2010 23:45:14 +0000 Subject: More version changes and make sure HttpClient connections are released git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1043772 13f79535-47bb-0310-9956-ffa450edef68 --- .../binding/atom/provider/AtomBindingInvoker.java | 58 ++++++++++++---------- 1 file changed, 33 insertions(+), 25 deletions(-) (limited to 'sca-java-2.x/trunk/modules/binding-atom-runtime/src') diff --git a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java index 9ad69d58a3..c1de646f54 100644 --- a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java +++ b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java @@ -22,6 +22,7 @@ import static org.apache.tuscany.sca.binding.atom.provider.AtomBindingUtil.entry import static org.apache.tuscany.sca.binding.atom.provider.AtomBindingUtil.feedEntry; import java.io.IOException; +import java.io.InputStream; import java.io.StringWriter; import java.util.ArrayList; import java.util.List; @@ -113,7 +114,9 @@ class AtomBindingInvoker implements Invoker { // Read the Atom entry if (status == 200) { - Document doc = abderaParser.parse(response.getEntity().getContent()); + InputStream content = response.getEntity().getContent(); + Document doc = abderaParser.parse(content); + content.close(); parsing = true; org.apache.abdera.model.Entry feedEntry = doc.getRoot(); @@ -145,11 +148,11 @@ class AtomBindingInvoker implements Invoker { } catch (Exception e) { msg.setFaultBody(new ServiceRuntimeException(e)); } finally { - if (!parsing) { - // Release the connection unless the Abdera parser is - // parsing the response, in this case it will release it - release(getMethod, response); - } + + // Release the connection unless the Abdera parser is + // parsing the response, in this case it will release it + release(getMethod, response); + } return msg; @@ -211,8 +214,9 @@ class AtomBindingInvoker implements Invoker { // Read the Atom entry if (status == 200 || status == 201) { - Document doc = - abderaParser.parse(postMethod.getEntity().getContent()); + InputStream content = postMethod.getEntity().getContent(); + Document doc = abderaParser.parse(content); + content.close(); parsing = true; org.apache.abdera.model.Entry createdEntry = doc.getRoot(); @@ -240,11 +244,11 @@ class AtomBindingInvoker implements Invoker { } catch (Exception e) { msg.setFaultBody(new ServiceRuntimeException(e)); } finally { - if (!parsing) { - // Release the connection unless the Abdera parser is - // parsing the response, in this case it will release it - release(postMethod, response); - } + + // Release the connection unless the Abdera parser is + // parsing the response, in this case it will release it + release(postMethod, response); + } return msg; @@ -408,7 +412,9 @@ class AtomBindingInvoker implements Invoker { // Read the Atom feed if (status == 200) { - Document doc = abderaParser.parse(response.getEntity().getContent()); + InputStream content = response.getEntity().getContent(); + Document doc = abderaParser.parse(content); + content.close(); parsing = true; Feed feed = null; @@ -451,11 +457,11 @@ class AtomBindingInvoker implements Invoker { } catch (Exception e) { msg.setFaultBody(new ServiceRuntimeException(e)); } finally { - if (!parsing) { - // Release the connection unless the Abdera parser is - // parsing the response, in this case it will release it - release(getMethod, response); - } + + // Release the connection unless the Abdera parser is + // parsing the response, in this case it will release it + release(getMethod, response); + } return msg; @@ -494,7 +500,9 @@ class AtomBindingInvoker implements Invoker { // Read the Atom feed if (status == 200) { - Document doc = abderaParser.parse(response.getEntity().getContent()); + InputStream content = response.getEntity().getContent(); + Document doc = abderaParser.parse(content); + content.close(); parsing = true; Feed feed = doc.getRoot(); @@ -530,11 +538,11 @@ class AtomBindingInvoker implements Invoker { } catch (Exception e) { msg.setFaultBody(new ServiceRuntimeException(e)); } finally { - if (!parsing) { - // Release the connection unless the Abdera parser is - // parsing the response, in this case it will release it - release(getMethod, response); - } + + // Release the connection unless the Abdera parser is + // parsing the response, in this case it will release it + release(getMethod, response); + } return msg; -- cgit v1.2.3