X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=rulemgt%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fholmes%2Frulemgt%2Fmsb%2FEngineIpList.java;h=992785f387eef4a2e6266e4d43852067f667c3ff;hb=37b3bb9b015069ba5e9ad1845de30467decb61d4;hp=cfccd18fe3b262e7c6eafc1902cf5e44eea0833b;hpb=1985d463e60ab79a2fadc4065a9ea19861933692;p=holmes%2Frule-management.git diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/msb/EngineIpList.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/msb/EngineIpList.java index cfccd18..992785f 100644 --- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/msb/EngineIpList.java +++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/msb/EngineIpList.java @@ -16,7 +16,10 @@ package org.onap.holmes.rulemgt.msb; +import java.io.IOException; +import lombok.extern.slf4j.Slf4j; import org.apache.http.HttpResponse; +import org.apache.http.impl.client.CloseableHttpClient; import org.jvnet.hk2.annotations.Service; import org.onap.holmes.common.api.entity.ServiceEntity; import org.onap.holmes.common.api.entity.ServiceNode4Query; @@ -30,6 +33,7 @@ import java.util.HashMap; import java.util.List; @Service +@Slf4j public class EngineIpList { private String[] msbAddrInfo; @@ -47,12 +51,22 @@ public class EngineIpList { public List getServiceCount()throws Exception{ String response; + CloseableHttpClient httpClient = null; try { + httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT); HttpResponse httpResponse = HttpsUtils - .get(url, new HashMap<>()); + .get(url, new HashMap<>(), httpClient); response = HttpsUtils.extractResponseEntity(httpResponse); } catch (Exception e) { throw e; + } finally { + if (httpClient != null) { + try { + httpClient.close(); + } catch (IOException e) { + log.warn("Failed to close http client!"); + } + } } ServiceEntity service = GsonUtil.jsonToBean(response, ServiceEntity.class); List nodesList = service.getNodes();