From 8dfd2a33c3d645b06e5cb05a811f739697c0ee2b Mon Sep 17 00:00:00 2001 From: Skip Wonnell Date: Wed, 19 Jul 2017 22:02:57 -0400 Subject: [APPC-93] Resource leak in appc.adapter.chef.chefclient.Utils Place instantiation of FileReader and BufferedReader inside a TWR Change-Id: Ibc0fffa76e536bdccca92731dc7ebc878faf67a1 Signed-off-by: Skip Wonnell --- .../java/org/openecomp/appc/adapter/chef/chefclient/Utils.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle') diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefclient/Utils.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefclient/Utils.java index fc64af5d4..07c983a43 100644 --- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefclient/Utils.java +++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefclient/Utils.java @@ -62,15 +62,9 @@ public class Utils { public static String signWithRSA(String inStr, String pemPath) { byte[] outStr = null; - BufferedReader br = null; - try { - br = new BufferedReader(new FileReader(pemPath)); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } Security.addProvider(new BouncyCastleProvider()); - try { - + try (FileReader fr = new FileReader(pemPath); + BufferedReader br = new BufferedReader(fr)) { PEMParser pemParser = new PEMParser(br); JcaPEMKeyConverter converter = new JcaPEMKeyConverter(); Object object = pemParser.readObject(); -- cgit 1.2.3-korg