Fixed CloseableHttpClient close issue 57/19257/2
authorshashikanth.vh <shashikanth.vh@huawei.com>
Tue, 17 Oct 2017 10:50:15 +0000 (16:20 +0530)
committerShashikanth VH <shashikanth.vh@huawei.com>
Tue, 17 Oct 2017 11:03:04 +0000 (11:03 +0000)
Issue-id: SO-228

Change-Id: I731227f4728d3eee5ce84b358c6422a44efdbdc3
Signed-off-by: shashikanth.vh <shashikanth.vh@huawei.com>
adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java

index 6c571f3..f51b272 100644 (file)
@@ -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);