fix https timeout get connection
[holmes/rule-management.git] / rulemgt / src / main / java / org / onap / holmes / rulemgt / bolt / enginebolt / EngineService.java
index aa0bf32..15af38d 100644 (file)
@@ -20,6 +20,9 @@ import java.util.HashMap;
 import javax.ws.rs.core.MediaType;\r
 import lombok.extern.slf4j.Slf4j;\r
 import org.apache.http.HttpResponse;\r
+import org.apache.http.client.methods.HttpDelete;\r
+import org.apache.http.client.methods.HttpPost;\r
+import org.apache.http.client.methods.HttpPut;\r
 import org.apache.http.entity.StringEntity;\r
 import org.apache.http.impl.client.CloseableHttpClient;\r
 import org.jvnet.hk2.annotations.Service;\r
@@ -41,10 +44,12 @@ public class EngineService {
         HashMap headers = createHeaders();\r
         String url = PREFIX + ip + PORT + RuleMgtConstant.ENGINE_PATH + "/" + packageName;\r
         CloseableHttpClient httpClient = null;\r
+        HttpDelete httpDelete = new HttpDelete(url);\r
         try {\r
             httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT);\r
-            return HttpsUtils.delete(url, headers, httpClient);\r
+            return HttpsUtils.delete(httpDelete, headers, httpClient);\r
         } finally {\r
+            httpDelete.releaseConnection();\r
             closeHttpClient(httpClient);\r
         }\r
     }\r
@@ -55,10 +60,12 @@ public class EngineService {
         HashMap headers = createHeaders();\r
         String url = PREFIX + ip + PORT + RuleMgtConstant.ENGINE_PATH;\r
         CloseableHttpClient httpClient = null;\r
+        HttpPost httpPost = new HttpPost(url);\r
         try {\r
             httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT);\r
-            return HttpsUtils.post(url, headers, new HashMap<>(), new StringEntity(content), httpClient);\r
+            return HttpsUtils.post(httpPost, headers, new HashMap<>(), new StringEntity(content), httpClient);\r
         } finally {\r
+            httpPost.releaseConnection();\r
             closeHttpClient(httpClient);\r
         }\r
     }\r
@@ -68,9 +75,10 @@ public class EngineService {
         HashMap headers = createHeaders();\r
         String url = PREFIX + ip + PORT + RuleMgtConstant.ENGINE_PATH;\r
         CloseableHttpClient httpClient = null;\r
+        HttpPut httpPut = new HttpPut(url);\r
         try {\r
             httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT);\r
-            return HttpsUtils.put(url, headers, new HashMap<>(), new StringEntity(content),httpClient);\r
+            return HttpsUtils.put(httpPut, headers, new HashMap<>(), new StringEntity(content),httpClient);\r
         } finally {\r
             closeHttpClient(httpClient);\r
         }\r