fix https timeout get connection
[holmes/common.git] / holmes-actions / src / main / java / org / onap / holmes / common / dmaap / Publisher.java
index adddd65..b3a9214 100644 (file)
@@ -17,6 +17,8 @@ package org.onap.holmes.common.dmaap;
 \r
 import java.io.IOException;\r
 import lombok.extern.slf4j.Slf4j;\r
+import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;\r
+import org.apache.http.client.methods.HttpPost;\r
 import org.apache.http.impl.client.CloseableHttpClient;\r
 import org.onap.holmes.common.dmaap.entity.PolicyMsg;\r
 import org.onap.holmes.common.exception.CorrelationException;\r
@@ -55,12 +57,14 @@ public class Publisher {
         headers.put("Accept", MediaType.APPLICATION_JSON);\r
         headers.put("Content-Type", MediaType.APPLICATION_JSON);\r
         CloseableHttpClient httpClient = null;\r
+        HttpPost httpPost = new HttpPost(url);\r
         try {\r
             httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT);\r
-            httpResponse = HttpsUtils.post(url, headers, new HashMap<>(), new StringEntity(content, "utf-8"), httpClient);\r
+            httpResponse = HttpsUtils.post(httpPost, headers, new HashMap<>(), new StringEntity(content, "utf-8"), httpClient);\r
         } catch (Exception e) {\r
             throw new CorrelationException("Failed to connect to DCAE.", e);\r
         } finally {\r
+            httpPost.releaseConnection();\r
             if (httpClient != null) {\r
                 try {\r
                     httpClient.close();\r