From 305eee7a0e8d74735ae8d41c83fce484030e988c Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Mon, 12 Feb 2018 10:22:53 +0530 Subject: Fix closure by try resource approach Issue-ID: CLI-92 Change-Id: I6375058625b51d2d15d397163c0aa20025114bc2 Signed-off-by: Kanagaraj Manickam k00365106 --- .../java/org/onap/cli/fw/utils/OnapCommandHelperUtils.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'framework/src/main') diff --git a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandHelperUtils.java b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandHelperUtils.java index 81589b09..e9ea81d4 100644 --- a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandHelperUtils.java +++ b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandHelperUtils.java @@ -42,12 +42,12 @@ public class OnapCommandHelperUtils { */ public static String findLastBuildTime() { String impBuildDate = ""; + JarFile jar = null; try { String path = OnapCommandUtils.class.getProtectionDomain().getCodeSource().getLocation().getPath(); - JarFile jar = new JarFile(path); + jar = new JarFile(path); Manifest manifest = jar.getManifest(); - jar.close(); Attributes attributes = manifest.getMainAttributes(); @@ -56,6 +56,14 @@ public class OnapCommandHelperUtils { catch (IOException e) // NOSONAR { //Ignore it as it will never occur + } finally { + if (jar != null) { + try { + jar.close(); + } catch (IOException e) { // NOSONAR + //Ignore it as it will never occur + } + } } return impBuildDate; -- cgit 1.2.3-korg