From 21cef616e10204d1a03472c381d0645654fc312c Mon Sep 17 00:00:00 2001 From: "shashikanth.vh" Date: Tue, 17 Oct 2017 16:20:15 +0530 Subject: Fixed CloseableHttpClient close issue Issue-id: SO-228 Change-Id: I731227f4728d3eee5ce84b358c6422a44efdbdc3 Signed-off-by: shashikanth.vh --- .../org/openecomp/mso/adapters/network/BpelRestClient.java | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'adapters/mso-network-adapter/src/main/java') diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java index 6c571f3e06..f51b27282c 100644 --- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java @@ -241,9 +241,6 @@ public class BpelRestClient { LOGGER.debug("Sending to BPEL server: "+bpelUrl); LOGGER.debug("Content is: "+toBpelStr); - //Client 4.3+ - CloseableHttpClient client = null; - //POST HttpPost post = new HttpPost(bpelUrl); if (credentials != null && !credentials.isEmpty()) @@ -263,8 +260,7 @@ public class BpelRestClient { //Client 4.3+ //Execute & GetResponse - try { - client = HttpClients.createDefault(); + try (CloseableHttpClient client = HttpClients.createDefault()) { CloseableHttpResponse response = client.execute(post); if (response != null) { lastResponseCode = response.getStatusLine().getStatusCode(); @@ -279,14 +275,6 @@ public class BpelRestClient { LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, error, "Camunda", "", MsoLogger.ErrorCode.AvailabilityError, "Exception sending Bpel notification", e); lastResponseCode = 900; lastResponse = ""; - } finally { - if(client != null){ - try { - client.close(); - } catch (IOException e) { - LOGGER.debug("Exception while closing client", e); - } - } } LOGGER.debug("Response code from BPEL server: "+lastResponseCode); LOGGER.debug("Response body is: "+lastResponse); -- cgit 1.2.3-korg