From 8cfa1b81d64c69c4a78dc5ac2b205418dabcbe91 Mon Sep 17 00:00:00 2001 From: Oleksandr Moliavko Date: Tue, 6 Aug 2019 11:59:56 +0300 Subject: Added close() call for InputStream instance to remove static analyzer warning about handle leak in getMsoAaiPassword() Issue-ID: SO-1841 Signed-off-by: Oleksandr Moliavko Change-Id: I2be9cc72f78275a80c6f03d806bea2ad275f23b4 --- .../src/main/java/org/onap/so/bpmn/common/util/CryptoHandler.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/CryptoHandler.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/CryptoHandler.java index dc2b3be073..5c0406cc9e 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/CryptoHandler.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/CryptoHandler.java @@ -24,6 +24,7 @@ package org.onap.so.bpmn.common.util; import java.io.IOException; +import java.io.InputStream; import java.security.GeneralSecurityException; import java.util.Properties; import org.onap.so.utils.CryptoUtils; @@ -40,7 +41,10 @@ public class CryptoHandler implements ICryptoHandler { public String getMsoAaiPassword() { Properties keyProp = new Properties(); try { - keyProp.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("urn.properties")); + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + InputStream rs = cl.getResourceAsStream("urn.properties"); + keyProp.load(rs); + rs.close(); return CryptoUtils.decrypt((String) keyProp.get(PROPERTY_KEY), MSO_KEY); } catch (GeneralSecurityException | IOException e) { logger.error(GENERAL_SECURITY_EXCEPTION_PREFIX + e.getMessage(), e); -- cgit 1.2.3-korg