summaryrefslogtreecommitdiffstats
path: root/tools/simple-wsclient/src
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/simple-wsclient/src
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/simple-wsclient/src')
-rw-r--r--tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/Application.java36
1 files changed, 28 insertions, 8 deletions
diff --git a/tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/Application.java b/tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/Application.java
index bfd6573bc..7c7d7e9c6 100644
--- a/tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/Application.java
+++ b/tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/Application.java
@@ -29,6 +29,8 @@ import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.lang3.Validate;
import org.onap.policy.apex.tools.common.CliOptions;
import org.onap.policy.apex.tools.common.CliParser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Simple console application with main method.
@@ -36,6 +38,8 @@ import org.onap.policy.apex.tools.common.CliParser;
* @author Sven van der Meer (sven.van.der.meer@ericsson.com)
*/
public final class Application {
+ // Get a reference to the logger
+ private static final Logger LOGGER = LoggerFactory.getLogger(Application.class);
/**
* Private constructor prevents subclassing.
@@ -133,11 +137,17 @@ public final class Application {
final SimpleEcho simpleEcho = new SimpleEcho(server, port, appName);
simpleEcho.connect();
} catch (final URISyntaxException uex) {
- System.err.println(appName + ": URI exception, could not create URI from server and port settings");
+ String message = appName + ": URI exception, could not create URI from server and port settings";
+ System.err.println(message);
+ LOGGER.warn(message, uex);
} catch (final NullPointerException nex) {
- System.err.println(appName + ": null pointer, server or port were null");
+ String message = appName + ": null pointer, server or port were null";
+ System.err.println(message);
+ LOGGER.warn(message, nex);
} catch (final IllegalArgumentException iex) {
- System.err.println(appName + ": illegal argument, server or port were blank");
+ String message = appName + ": illegal argument, server or port were blank";
+ System.err.println(message);
+ LOGGER.warn(message, iex);
}
}
@@ -167,15 +177,25 @@ public final class Application {
final SimpleConsole simpleConsole = new SimpleConsole(server, port, appName);
simpleConsole.runClient();
} catch (final URISyntaxException uex) {
- System.err.println(appName + ": URI exception, could not create URI from server and port settings");
+ String message = appName + ": URI exception, could not create URI from server and port settings";
+ System.err.println(message);
+ LOGGER.warn(message, uex);
} catch (final NullPointerException nex) {
- System.err.println(appName + ": null pointer, server or port were null");
+ String message = appName + ": null pointer, server or port were null";
+ System.err.println(message);
+ LOGGER.warn(message, nex);
} catch (final IllegalArgumentException iex) {
- System.err.println(appName + ": illegal argument, server or port were blank");
+ String message = appName + ": illegal argument, server or port were blank";
+ System.err.println(message);
+ LOGGER.warn(message, iex);
} catch (final NotYetConnectedException nex) {
- System.err.println(appName + ": not yet connected, connection to server took too long");
+ String message = appName + ": not yet connected, connection to server took too long";
+ System.err.println(message);
+ LOGGER.warn(message, nex);
} catch (final IOException ioe) {
- System.err.println(appName + ": IO exception, something went wrong on the standard input");
+ String message = appName + ": IO exception, something went wrong on the standard input";
+ System.err.println(message);
+ LOGGER.warn(message, ioe);
}
}
}