diff options
author | Tomek Kaminski <tomasz.kaminski@nokia.com> | 2018-01-02 15:28:57 +0100 |
---|---|---|
committer | Tomek Kaminski <tomasz.kaminski@nokia.com> | 2018-01-02 15:36:47 +0100 |
commit | 6441b69bd31a3deb7104958e37044ceaafb0d5ca (patch) | |
tree | 83e00d19e406d6123c25c5732fd19a78b12983b0 /appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main | |
parent | c1d325bb009a21ccb4d89f8562f89a36cfa069ed (diff) |
Fix for sonar blocker
Add missing close operation on ClosableHttpClient instance in executeHttpRequest method of RestAdapterImpl.java
Resolve sonar blocker using try-with-resources clause.
Change-Id: Ibaf5eba70abd4a042708eb686da073e673d547fb
Issue-ID: APPC-364
Signed-off-by: Tomek Kaminski <tomasz.kaminski@nokia.com>
Diffstat (limited to 'appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main')
-rw-r--r-- | appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/onap/appc/adapter/rest/impl/RestAdapterImpl.java | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/onap/appc/adapter/rest/impl/RestAdapterImpl.java b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/onap/appc/adapter/rest/impl/RestAdapterImpl.java index bbb37f4cf..b45a5da5c 100644 --- a/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/onap/appc/adapter/rest/impl/RestAdapterImpl.java +++ b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/onap/appc/adapter/rest/impl/RestAdapterImpl.java @@ -35,6 +35,7 @@ import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPut; import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import org.glassfish.grizzly.http.util.HttpStatus; @@ -177,8 +178,7 @@ public class RestAdapterImpl implements RestAdapter { } public void executeHttpRequest(HttpRequestBase httpRequest, RequestContext rc){ - try { - HttpClient httpClient = HttpClients.createDefault(); + try (CloseableHttpClient httpClient = HttpClients.createDefault()) { HttpResponse response = httpClient.execute(httpRequest); int responseCode = response.getStatusLine().getStatusCode(); HttpEntity entity = response.getEntity(); |