diff options
author | liamfallon <liam.fallon@ericsson.com> | 2018-09-17 15:50:34 +0100 |
---|---|---|
committer | liamfallon <liam.fallon@ericsson.com> | 2018-09-17 15:50:42 +0100 |
commit | 565922bbe60fc0a9d015ce00ef8733e6ddfe905c (patch) | |
tree | ab0766163970478854507c389c3a952847af9c50 /tools/tools-common/src/main/java/org | |
parent | 421672e34425963b97184104416bb131d5e7903a (diff) |
Fix sonar issues in apex utilties
This change fixes Sonar issues in apex command line
utilities.
Issue-ID: POLICY-1034
Change-Id: Ib63a3d4107260c5909405e6f0d899279da869028
Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'tools/tools-common/src/main/java/org')
-rw-r--r-- | tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java | 38 |
1 files changed, 21 insertions, 17 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 267584952..1b4ef06c4 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 @@ -20,6 +20,7 @@ package org.onap.policy.apex.tools.common; +import java.io.PrintStream; import java.util.ArrayList; import java.util.List; @@ -72,6 +73,9 @@ public final class Console { /** Configuration for a collecting warning messages. */ public static final int CONFIG_COLLECT_WARNINGS = 0b0010; + // Input and output streams + private static final PrintStream ERR_STREAM = System.err; + /** The setting for message types, set using type flags. */ private int types; @@ -193,7 +197,7 @@ public final class Console { err.append(MessageFormatter.arrayFormat(message, objects).getMessage()); if ((types & TYPE_ERROR) == TYPE_ERROR) { - System.err.println(err.build()); + ERR_STREAM.println(err.build()); } if ((configuration & CONFIG_COLLECT_ERRORS) == CONFIG_COLLECT_ERRORS) { errors.add(err.build()); @@ -222,7 +226,7 @@ public final class Console { warn.append(MessageFormatter.arrayFormat(message, objects).getMessage()); if ((types & TYPE_WARNING) == TYPE_WARNING) { - System.err.println(warn.build()); + ERR_STREAM.println(warn.build()); } if ((configuration & CONFIG_COLLECT_WARNINGS) == CONFIG_COLLECT_WARNINGS) { warnings.add(warn.build()); @@ -243,9 +247,9 @@ public final class Console { if ((types & TYPE_INFO) == TYPE_INFO) { if (appName != null) { - System.err.print(appName + ": "); + ERR_STREAM.print(appName + ": "); } - System.err.println(MessageFormatter.arrayFormat(message, objects).getMessage()); + ERR_STREAM.println(MessageFormatter.arrayFormat(message, objects).getMessage()); } } @@ -263,10 +267,10 @@ public final class Console { if ((types & TYPE_PROGRESS) == TYPE_PROGRESS) { if (appName != null) { - System.err.print(appName + ": "); + ERR_STREAM.print(appName + ": "); } - System.err.print("progress: "); - System.err.println(MessageFormatter.arrayFormat(message, objects).getMessage()); + ERR_STREAM.print("progress: "); + ERR_STREAM.println(MessageFormatter.arrayFormat(message, objects).getMessage()); } } @@ -284,10 +288,10 @@ public final class Console { if ((types & TYPE_DEBUG) == TYPE_DEBUG) { if (appName != null) { - System.err.print(appName + ": "); + ERR_STREAM.print(appName + ": "); } - System.err.print("debug: "); - System.err.println(MessageFormatter.arrayFormat(message, objects).getMessage()); + ERR_STREAM.print("debug: "); + ERR_STREAM.println(MessageFormatter.arrayFormat(message, objects).getMessage()); } } @@ -305,10 +309,10 @@ public final class Console { if ((types & TYPE_TRACE) == TYPE_TRACE) { if (appName != null) { - System.err.print(appName + ": "); + ERR_STREAM.print(appName + ": "); } - System.err.print("trace: "); - System.err.println(MessageFormatter.arrayFormat(message, objects).getMessage()); + ERR_STREAM.print("trace: "); + ERR_STREAM.println(MessageFormatter.arrayFormat(message, objects).getMessage()); } } @@ -324,13 +328,13 @@ public final class Console { if ((types & TYPE_STACKTRACE) == TYPE_STACKTRACE) { if (appName != null) { - System.err.print(appName + ": "); + ERR_STREAM.print(appName + ": "); } - System.err.println(" exception message: " + exception.getMessage()); + ERR_STREAM.println(" exception message: " + exception.getMessage()); if (exception.getCause() != null) { - System.err.println(" exception cause: " + exception.getCause()); + ERR_STREAM.println(" exception cause: " + exception.getCause()); } - System.err.println("for exception stack trace, please refer logs."); + ERR_STREAM.println("for exception stack trace, please refer logs."); XLoggerFactory.getXLogger(Console.class).error("stacktrace", exception); } } |