From 2267daa571a3f072a4718efa9509e24479b52278 Mon Sep 17 00:00:00 2001 From: laszlohordos Date: Thu, 30 Oct 2014 18:53:33 +0100 Subject: [PATCH] Release CloseableHttpResponse I'm using CloseableHttpResponse in 4.3 and I didn't find any other way to release the connection back to the pool. The default implementation close the DefaultHttpClient but I don't use that class. --- .../communication/response/AbstractODataResponse.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AbstractODataResponse.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AbstractODataResponse.java index 4e8ba49242..a2f2c5492d 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AbstractODataResponse.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AbstractODataResponse.java @@ -20,6 +20,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.PipedInputStream; @@ -282,6 +283,14 @@ public ODataResponse initFromEnclosedPart(final InputStream part) { public void close() { odataClient.getConfiguration().getHttpClientFactory().close(httpClient); + if (res instanceof Closeable){ + try { + ((Closeable)res).close(); + } catch (IOException e) { + LOG.error("Error closing HttpResponse", e); + throw new IllegalStateException(e); + } + } if (batchInfo != null) { batchInfo.setValidBatch(false); }