camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/2] camel git commit: CAMEL-9331: Thread leak in Http4Endpoint, doStop() does not close() the httpClient. Thanks to Aaron Whiteside for the patch.
Date Wed, 18 Nov 2015 08:28:49 GMT
CAMEL-9331: Thread leak in Http4Endpoint, doStop() does not close() the httpClient. Thanks
to Aaron Whiteside for the patch.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/106e75f5
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/106e75f5
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/106e75f5

Branch: refs/heads/camel-2.16.x
Commit: 106e75f5fe38bea1df81115fef9f532ef4282eaa
Parents: c95ffb8
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Wed Nov 18 09:31:48 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Nov 18 09:32:03 2015 +0100

----------------------------------------------------------------------
 .../org/apache/camel/component/http4/HttpEndpoint.java    | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/106e75f5/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
index 57e9795..c5c82bc 100644
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.http4;
 
+import java.io.Closeable;
 import java.net.URI;
 import java.net.URISyntaxException;
 
@@ -27,6 +28,7 @@ import org.apache.camel.http.common.HttpCommonEndpoint;
 import org.apache.camel.http.common.HttpHelper;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
+import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.http.HttpHost;
 import org.apache.http.client.CookieStore;
@@ -55,7 +57,7 @@ public class HttpEndpoint extends HttpCommonEndpoint {
     private HttpClientConfigurer httpClientConfigurer;
     private HttpClientConnectionManager clientConnectionManager;
     private HttpClientBuilder clientBuilder;
-    private  HttpClient httpClient;
+    private HttpClient httpClient;
 
     @UriParam(label = "producer")
     private CookieStore cookieStore = new BasicCookieStore();
@@ -130,6 +132,9 @@ public class HttpEndpoint extends HttpCommonEndpoint {
         clientBuilder.setDefaultCookieStore(cookieStore);
         // setup the httpConnectionManager
         clientBuilder.setConnectionManager(clientConnectionManager);
+        if (getClientConnectionManager() == getComponent().getClientConnectionManager())
{
+            clientBuilder.setConnectionManagerShared(true);
+        }
 
         // configure http proxy from camelContext
         if (ObjectHelper.isNotEmpty(getCamelContext().getProperty("http.proxyHost")) &&
ObjectHelper.isNotEmpty(getCamelContext().getProperty("http.proxyPort"))) {
@@ -175,6 +180,9 @@ public class HttpEndpoint extends HttpCommonEndpoint {
             // need to shutdown the ConnectionManager
             clientConnectionManager.shutdown();
         }
+        if (httpClient != null && httpClient instanceof Closeable) {
+            IOHelper.close((Closeable)httpClient);
+        }
     }
 
     // Properties


Mime
View raw message