From e4da736f34d7f1fc91fb1370d29f927a9e2ebe2d Mon Sep 17 00:00:00 2001 From: ramverma Date: Thu, 2 Aug 2018 12:50:09 +0100 Subject: Fixing sonar vulnerabilities in apex-pdp Changed the Console class to use logger only for printing stack trace, as the class is meant to be used for CLI usage. Changed the CLIParser to use Console class for printing messages. Changed the client-editor to be hosted on localhost by default, to follow the same what others clients (deployment, monitoring & client full) are doing. Change-Id: I6565b4b35a93b3708b926bfee04d79ead6b5346e Issue-ID: POLICY-954 Signed-off-by: ramverma --- .../main/java/org/onap/policy/apex/tools/common/CliParser.java | 4 ++-- .../src/main/java/org/onap/policy/apex/tools/common/Console.java | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'tools/tools-common/src') diff --git a/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/CliParser.java b/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/CliParser.java index 588abfc6b..31692dc21 100644 --- a/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/CliParser.java +++ b/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/CliParser.java @@ -81,8 +81,8 @@ public class CliParser { try { cmd = parser.parse(options, args); } catch (final ParseException ex) { - System.err.println("Parsing failed. Reason: " + ex.getMessage()); - ex.printStackTrace(); + Console.CONSOLE.error("Parsing failed, see reason and cause below"); + Console.CONSOLE.stacktrace(ex); } return cmd; } 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 571333147..d76caa333 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,7 @@ import java.util.List; import org.apache.commons.lang3.StringUtils; import org.apache.commons.text.StrBuilder; +import org.slf4j.ext.XLoggerFactory; import org.slf4j.helpers.MessageFormatter; /** @@ -326,12 +327,12 @@ public final class Console { if (appName != null) { System.err.print(appName + ": "); } - System.err.println("exception stack trace: "); - System.err.println(" - message: " + exception.getMessage()); + System.err.println(" exception message: " + exception.getMessage()); if (exception.getCause() != null) { - System.err.println(" - cause: " + exception.getCause()); + System.err.println(" exception cause: " + exception.getCause()); } - exception.printStackTrace(); + System.err.println("for exception stack trace, please refer logs."); + XLoggerFactory.getXLogger(Console.class).error("stacktrace", exception); } } -- cgit 1.2.3-korg