From 3ebdcbdb674900fd441dd67a471b80a62cbe144d Mon Sep 17 00:00:00 2001 From: Jegadeesh Babu Date: Thu, 14 Mar 2019 16:03:09 +0530 Subject: Refactored local var which hides class variable Sonar fix Issue-ID: APPC-1536 Change-Id: I2aa494d4fb13f6422382232cb05c94c333650f85 Signed-off-by: Jegadeesh Babu --- .../adapter/ansible/impl/AnsibleAdapterImpl.java | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main') diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/impl/AnsibleAdapterImpl.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/impl/AnsibleAdapterImpl.java index 91125b0ac..b352dbebc 100644 --- a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/impl/AnsibleAdapterImpl.java +++ b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/impl/AnsibleAdapterImpl.java @@ -234,7 +234,7 @@ public class AnsibleAdapterImpl implements AnsibleAdapter { // 3. DEFAULT (trust only well known certificates). This is standard behavior to // which it will // revert. To be used in PROD - ConnectionBuilder httpClient = null; + ConnectionBuilder httpClientLocal = null; try { String clientType = props.getProperty(CLIENT_TYPE_PROPERTY_NAME); logger.info("Ansible http client type set to " + clientType); @@ -242,24 +242,24 @@ public class AnsibleAdapterImpl implements AnsibleAdapter { if ("TRUST_ALL".equals(clientType)) { logger.info( "Creating http client to trust ALL ssl certificates. WARNING. This should be done only in dev environments"); - httpClient = new ConnectionBuilder(1, timeout); + httpClientLocal = new ConnectionBuilder(1, timeout); } else if ("TRUST_CERT".equals(clientType)) { // set path to keystore file String trustStoreFile = props.getProperty(TRUSTSTORE_PROPERTY_NAME); String key = props.getProperty(TRUSTPASSWD_PROPERTY_NAME); char[] trustStorePasswd = EncryptionTool.getInstance().decrypt(key).toCharArray(); logger.info("Creating http client with trustmanager from " + trustStoreFile); - httpClient = new ConnectionBuilder(trustStoreFile, trustStorePasswd, timeout, serverIP); + httpClientLocal = new ConnectionBuilder(trustStoreFile, trustStorePasswd, timeout, serverIP); } else { logger.info("Creating http client with default behaviour"); - httpClient = new ConnectionBuilder(0, timeout); + httpClientLocal = new ConnectionBuilder(0, timeout); } } catch (Exception e) { logger.error("Error Getting HTTP Connection Builder due to Unknown Exception", e); } logger.info("Got HTTP Connection Builder"); - return httpClient; + return httpClientLocal; } // Public Method to post request to execute playbook. Posts the following back @@ -486,12 +486,12 @@ public class AnsibleAdapterImpl implements AnsibleAdapter { SvcLogicContext ctx) { AnsibleResult testResult = null; - ConnectionBuilder httpClient = getHttpConn(defaultSocketTimeout, ""); + ConnectionBuilder httpClientLocal = getHttpConn(defaultSocketTimeout, ""); if (!testMode) { - if(httpClient!=null) { - httpClient.setHttpContext(user, password); - testResult = httpClient.post(agentUrl, payload); - httpClient.close(); + if(httpClientLocal!=null) { + httpClientLocal.setHttpContext(user, password); + testResult = httpClientLocal.post(agentUrl, payload); + httpClientLocal.close(); } } else { testResult = testServer.Post(agentUrl, payload); @@ -516,14 +516,14 @@ public class AnsibleAdapterImpl implements AnsibleAdapter { while (System.currentTimeMillis() < endTime) { String serverIP = ctx.getAttribute("ServerIP"); - ConnectionBuilder httpClient = getHttpConn(defaultSocketTimeout, serverIP); + ConnectionBuilder httpClientLocal = getHttpConn(defaultSocketTimeout, serverIP); logger.info("Querying ansible GetResult URL = " + agentUrl); if (!testMode) { - if(httpClient!=null) { - httpClient.setHttpContext(user, password); - testResult = httpClient.get(agentUrl); - httpClient.close(); + if(httpClientLocal!=null) { + httpClientLocal.setHttpContext(user, password); + testResult = httpClientLocal.get(agentUrl); + httpClientLocal.close(); } } else { testResult = testServer.Get(agentUrl); -- cgit 1.2.3-korg