summaryrefslogtreecommitdiffstats
path: root/javatoscachecker
diff options
context:
space:
mode:
authorParshad Patel <pars.patel@samsung.com>2019-03-25 15:24:32 +0900
committerParshad Patel <pars.patel@samsung.com>2019-03-25 15:35:32 +0900
commita8aadf17072c22e7093c3aefeca215d4b10e125e (patch)
treeaa17f1d2aa3839184e1d7a7958588089fe06ca7a /javatoscachecker
parentaf877fe9df8af4abb0745b095fd134cbab8de29d (diff)
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 <pars.patel@samsung.com>
Diffstat (limited to 'javatoscachecker')
-rw-r--r--javatoscachecker/checker/src/main/java/org/onap/tosca/checker/CommonLocator.java13
-rw-r--r--javatoscachecker/kwalify/src/main/java/kwalify/BaseException.java55
-rw-r--r--javatoscachecker/kwalify/src/main/java/kwalify/CommandOptionException.java20
3 files changed, 55 insertions, 33 deletions
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);
}
}
diff --git a/javatoscachecker/kwalify/src/main/java/kwalify/BaseException.java b/javatoscachecker/kwalify/src/main/java/kwalify/BaseException.java
index cc40f58..f12d63d 100644
--- a/javatoscachecker/kwalify/src/main/java/kwalify/BaseException.java
+++ b/javatoscachecker/kwalify/src/main/java/kwalify/BaseException.java
@@ -52,38 +52,47 @@ package kwalify;
*/
public abstract class BaseException extends KwalifyRuntimeException implements Comparable {
- String _ypath;
- transient Object _value;
- transient Rule _rule;
- String _errorSymbol;
- int _linenum = -1;
-
+ final String ypath;
+ final transient Object value;
+ final transient Rule rule;
+ final String errorSymbol;
+ int linenum = -1;
+
public BaseException(String message, String ypath, Object value, Rule rule, String errorSymbol) {
super(message);
- _ypath = ypath;
- _value = value;
- _rule = rule;
- _errorSymbol = errorSymbol;
+ this.ypath = ypath;
+ this.value = value;
+ this.rule = rule;
+ this.errorSymbol = errorSymbol;
}
- public String getPath() { return _ypath.equals("") ? "/" : _ypath; }
- //public void setPath(String ypath) { _ypath = ypath; }
+ public String getPath() {
+ return ypath.isEmpty() ? "/" : ypath;
+ }
- public Object getValue() { return _value; }
- //public void setValue(Object value) { _value = value; }
+ public Object getValue() {
+ return value;
+ }
- public Rule getRule() { return _rule; }
- //
- //public void setRule(Rule rule) { _rule = rule; }
+ public Rule getRule() {
+ return rule;
+ }
- public String getErrorSymbol() { return _errorSymbol; }
- //public void setErrorSymbol(String errorSymbol) { _errorSymbol = errorSymbol; }
+ public String getErrorSymbol() {
+ return errorSymbol;
+ }
- public int getLineNumber() { return _linenum; }
- public void setLineNumber(int linenum) { _linenum = linenum; }
+ public int getLineNumber() {
+ return linenum;
+ }
+
+ public void setLineNumber(int linenum) {
+ this.linenum = linenum;
+ }
public int compareTo(Object obj) {
- int n = ((ValidationException)obj).getLineNumber();
- return _linenum - n;
+ int n = ((ValidationException) obj).getLineNumber();
+ return linenum - n;
}
+
}
diff --git a/javatoscachecker/kwalify/src/main/java/kwalify/CommandOptionException.java b/javatoscachecker/kwalify/src/main/java/kwalify/CommandOptionException.java
index 2e6e9a5..6d8ae4d 100644
--- a/javatoscachecker/kwalify/src/main/java/kwalify/CommandOptionException.java
+++ b/javatoscachecker/kwalify/src/main/java/kwalify/CommandOptionException.java
@@ -53,19 +53,21 @@ package kwalify;
public class CommandOptionException extends KwalifyException {
private static final long serialVersionUID = 6433387612335104714L;
- private String _error_symbol = null;
- private char _option;
+ private final String errorSymbol;
+ private final char option;
- public CommandOptionException(String message, char option, String error_symbol) {
+ public CommandOptionException(String message, char option, String errorSymbol) {
super(message);
- _option = option;
- _error_symbol = error_symbol;
+ this.option = option;
+ this.errorSymbol = errorSymbol;
}
- public String getErrorSymbol() { return _error_symbol; }
- public void setErrorSymbol(String error_symbol) { _error_symbol = error_symbol; }
+ public String getErrorSymbol() {
+ return errorSymbol;
+ }
- public char getOption() { return _option; }
- public void setOption(char option) { _option = option; }
+ public char getOption() {
+ return option;
+ }
}