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=2e9199347154d4d4b16d10b68dc008ac0b6b0a6f;hb=8635bde272f6f2da05dd4dc274e0d91a640c0088;hp=9b307050e19f10bc24353baf04a495827b7f288b;hpb=df4bde91310a471a5489917e3a07359ef790d9cb;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 9b30705..2e91993 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 @@ -51,33 +51,24 @@ public class EngineIpList { } public List getServiceCount()throws Exception{ - String response; - CloseableHttpClient httpClient = null; - HttpGet httpGet = new HttpGet(url); - try { - httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT); - HttpResponse httpResponse = HttpsUtils - .get(httpGet, new HashMap<>(), httpClient); - response = HttpsUtils.extractResponseEntity(httpResponse); - } catch (Exception e) { - throw e; - } finally { - httpGet.releaseConnection(); - 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(); - List ipList = new ArrayList<>(); - for(ServiceNode4Query node : nodesList){ - ipList.add(node.getIp()); - } - return ipList; + String response; + HttpGet httpGet = new HttpGet(url); + try (CloseableHttpClient httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT)) { + HttpResponse httpResponse = HttpsUtils.get(httpGet, new HashMap<>(), httpClient); + response = HttpsUtils.extractResponseEntity(httpResponse); + } catch (Exception e) { + throw e; + } finally { + httpGet.releaseConnection(); + + } + ServiceEntity service = GsonUtil.jsonToBean(response, ServiceEntity.class); + List nodesList = service.getNodes(); + List ipList = new ArrayList<>(); + for (ServiceNode4Query node : nodesList) { + ipList.add(node.getIp()); + } + return ipList; }