diff options
author | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2018-02-12 10:22:53 +0530 |
---|---|---|
committer | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2018-02-12 11:26:29 +0530 |
commit | 305eee7a0e8d74735ae8d41c83fce484030e988c (patch) | |
tree | 8d8fe204542d7a271a6b63bb85bd09736fe73fe3 /framework/src/main | |
parent | 33596b6fca3804b5e9e685dbe144b7a6879fa96c (diff) |
Fix closure by try resource approach
Issue-ID: CLI-92
Change-Id: I6375058625b51d2d15d397163c0aa20025114bc2
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'framework/src/main')
-rw-r--r-- | framework/src/main/java/org/onap/cli/fw/utils/OnapCommandHelperUtils.java | 12 |
1 files changed, 10 insertions, 2 deletions
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; |