From ce2b1e181d2ef074d4f12eeec4342c4020273327 Mon Sep 17 00:00:00 2001 From: AvinashS Date: Wed, 20 Sep 2017 18:18:48 +0530 Subject: File reader needs close Potential file stream leak Change-Id: Ib72a7f07bd687c1858b2e06d0d2dcea2271cc519 IssueId: VNFSDK-93 Signed-off-by: AvinashS --- .../java/org/onap/validation/csar/CsarValidator.java | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'csarvalidation/src/main/java/org/onap') diff --git a/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java b/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java index 7d252e1..891f83e 100644 --- a/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java +++ b/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java @@ -100,10 +100,8 @@ public class CsarValidator { String cfile = csarFiles.get(CommonConstants.CSAR_META); if (!cfile.isEmpty()) { File file = new File(cfile); - BufferedReader reader = null; - try { - reader = new BufferedReader(new FileReader(file)); + try(BufferedReader reader = new BufferedReader(new FileReader(file))) { String tempString = null; while ((tempString = reader.readLine()) != null) { if (!tempString.equals("")) { @@ -133,17 +131,7 @@ public class CsarValidator { } } catch (IOException e2) { LOG.error("Exception caught while validateCsarMeta ! " + e2.getMessage()); - } finally { - if (reader != null) { - try { - reader.close(); - - } catch (IOException e1) { - LOG.error("close reader failed ! " + e1.getMessage()); - } - } - - } + } } return false; -- cgit 1.2.3-korg