aboutsummaryrefslogtreecommitdiffstats
path: root/tools/tools-common/src/main/java
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-09-14 16:45:06 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-09-14 16:45:17 +0100
commita65e4772f4557a109917532b2d9c49680ce3bb15 (patch)
tree1669786f0b3ce82e005debc53218825d537841c8 /tools/tools-common/src/main/java
parent6d72a4a1e5d8678ecd8b093480ea9543089015b0 (diff)
Fix exception not logged or rethrown
Eclipse sonarlint does not check for exception dropping by default, it must be configured. This commit addresses exception dropping in apex. Change-Id: I406838990b3424c2912124b25d7326502cacc96c Issue-ID: POLICY-1034 Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'tools/tools-common/src/main/java')
-rw-r--r--tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java3
-rw-r--r--tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/OutputFile.java10
2 files changed, 11 insertions, 2 deletions
diff --git a/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java b/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java
index 28337fdeb..aacc22013 100644
--- a/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java
+++ b/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java
@@ -25,6 +25,8 @@ import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StrBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.slf4j.ext.XLoggerFactory;
import org.slf4j.helpers.MessageFormatter;
@@ -36,7 +38,6 @@ import org.slf4j.helpers.MessageFormatter;
* @author Sven van der Meer (sven.van.der.meer@ericsson.com)
*/
public final class Console {
-
/** The console as static object. */
public static final Console CONSOLE = new Console();
diff --git a/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/OutputFile.java b/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/OutputFile.java
index b529a7e08..59d15d19d 100644
--- a/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/OutputFile.java
+++ b/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/OutputFile.java
@@ -32,6 +32,8 @@ import java.nio.file.Path;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Standard output file handling and tests.
@@ -39,6 +41,8 @@ import org.apache.commons.lang3.Validate;
* @author Sven van der Meer (sven.van.der.meer@ericsson.com)
*/
public class OutputFile {
+ // Get a reference to the logger
+ private static final Logger LOGGER = LoggerFactory.getLogger(OutputFile.class);
/** The output file name. */
private final String fileName;
@@ -86,6 +90,7 @@ public class OutputFile {
try {
return new BufferedWriter(new FileWriter(toFile()));
} catch (final IOException e) {
+ LOGGER.warn("write error", e);
return null;
}
}
@@ -99,6 +104,7 @@ public class OutputFile {
try {
return new FileOutputStream(toFile());
} catch (final IOException e) {
+ LOGGER.warn("stream creation error", e);
return null;
}
}
@@ -123,7 +129,9 @@ public class OutputFile {
try {
file.createNewFile();
} catch (final IOException e) {
- return "could not create output file: " + e.getMessage();
+ String message = "could not create output file: " + e.getMessage();
+ LOGGER.warn(message, e);
+ return message;
}
}