From a8aadf17072c22e7093c3aefeca215d4b10e125e Mon Sep 17 00:00:00 2001 From: Parshad Patel Date: Mon, 25 Mar 2019 15:24:32 +0900 Subject: Fix sonar issues in modeling/toscaparsers Fix Use try-with-resources or close this "InputStream" in a "finally" clause Fix Either log or rethrow this exception issue Fix Make field final issue Issue-ID: MODELING-154 Change-Id: I677051b4cff7cbd5e9c99acfd1bc5be3ae4c5036 Signed-off-by: Parshad Patel --- .../src/main/java/org/onap/tosca/checker/CommonLocator.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'javatoscachecker/checker/src') diff --git a/javatoscachecker/checker/src/main/java/org/onap/tosca/checker/CommonLocator.java b/javatoscachecker/checker/src/main/java/org/onap/tosca/checker/CommonLocator.java index f650f9e..e71eaa4 100644 --- a/javatoscachecker/checker/src/main/java/org/onap/tosca/checker/CommonLocator.java +++ b/javatoscachecker/checker/src/main/java/org/onap/tosca/checker/CommonLocator.java @@ -97,7 +97,16 @@ public class CommonLocator implements TargetLocator { catch (IOException iox) { log.log(Level.WARNING, "The path " + theName + " is an absolute uri but it canont be opened", iox); return null; - } + }finally { + if (pis!= null) { + try { + pis.close(); + } + catch (IOException iox) { + log.log(Level.FINER,"Error while closing input stream",iox); + } + } + } } } catch(URISyntaxException urisx) { @@ -123,6 +132,7 @@ public class CommonLocator implements TargetLocator { pis.close(); } catch (IOException iox) { + log.log(Level.FINER,"Error while closing input stream",iox); } } } @@ -135,6 +145,7 @@ public class CommonLocator implements TargetLocator { return new Target(theName, purl.toURI()); } catch (URISyntaxException urisx) { + log.log(Level.FINER,"Error while creating Target",urisx); } } -- cgit 1.2.3-korg