From 8e7e20e0d16c5ea42eec3c04d0a2d5e7e407420c Mon Sep 17 00:00:00 2001 From: Arindam Mondal Date: Mon, 13 Aug 2018 14:25:12 +0900 Subject: Sonar issue Major Issue-ID: SO-852 Change-Id: Ia0d58c52884abdd1f752dc6671d315b8516812e6 Signed-off-by: Arindam Mondal --- common/src/main/java/org/onap/so/client/RestClientSSL.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/common/src/main/java/org/onap/so/client/RestClientSSL.java b/common/src/main/java/org/onap/so/client/RestClientSSL.java index 461bb5832c..8eaeee97ee 100644 --- a/common/src/main/java/org/onap/so/client/RestClientSSL.java +++ b/common/src/main/java/org/onap/so/client/RestClientSSL.java @@ -72,23 +72,15 @@ public abstract class RestClientSSL extends RestClient { private KeyStore getKeyStore() { KeyStore ks = null; char[] password = System.getProperty(RestClientSSL.SSL_KEY_STORE_PASSWORD_KEY).toCharArray(); - FileInputStream fis = null; - try { + try(FileInputStream fis = new FileInputStream(System.getProperty(RestClientSSL.SSL_KEY_STORE_KEY))) { ks = KeyStore.getInstance(KeyStore.getDefaultType()); - fis = new FileInputStream(System.getProperty(RestClientSSL.SSL_KEY_STORE_KEY)); + ks.load(fis, password); } catch(Exception e) { return null; } - finally { - if (fis != null) { - try { - fis.close(); - } - catch(Exception e) {} - } - } + return ks; } } -- cgit 1.2.3-korg