summaryrefslogtreecommitdiffstats
path: root/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src
diff options
context:
space:
mode:
authorSkip Wonnell <kw5258@att.com>2017-07-21 08:03:48 -0400
committerSkip Wonnell <skip@att.com>2017-07-27 10:11:15 -0500
commitbfebc0599832ee03bfa74117d56cc66bb063ce00 (patch)
tree7a2bf3db96fa59a86691e6fabde0f5085806d86e /appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src
parent8dfd2a33c3d645b06e5cb05a811f739697c0ee2b (diff)
Fix resource leak in ChefAdapterImpl.java
Convert to Closeable versions of HttpClient and HttpResponse and instantiate both inside a TWR. Change-Id: I37ac34bab545592f51fb054068065fa1c00f7224 Signed-off-by: Skip Wonnell <kw5258@att.com> Issue: APPC-94
Diffstat (limited to 'appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src')
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/impl/ChefAdapterImpl.java9
1 files changed, 4 insertions, 5 deletions
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/impl/ChefAdapterImpl.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/impl/ChefAdapterImpl.java
index ac0a78b0e..9dc50e516 100644
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/impl/ChefAdapterImpl.java
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/impl/ChefAdapterImpl.java
@@ -594,11 +594,10 @@ public class ChefAdapterImpl implements ChefAdapter {
RequestContext rc = new RequestContext(ctx);
rc.isAlive();
- try {
- HttpGet httpGet = new HttpGet(tVmIp);
- HttpClient httpClient = HttpClients.createDefault();
- HttpResponse response = null;
- response = httpClient.execute(httpGet);
+ HttpGet httpGet = new HttpGet(tVmIp);
+ try ( CloseableHttpClient httpClient = HttpClients.createDefault();
+ CloseableHttpResponse response = httpClient.execute(httpGet); )
+ {
int responseCode = response.getStatusLine().getStatusCode();
HttpEntity entity = response.getEntity();
String responseOutput = EntityUtils.toString(entity);