diff options
author | liamfallon <liam.fallon@ericsson.com> | 2018-09-14 16:45:06 +0100 |
---|---|---|
committer | liamfallon <liam.fallon@ericsson.com> | 2018-09-14 16:45:17 +0100 |
commit | a65e4772f4557a109917532b2d9c49680ce3bb15 (patch) | |
tree | 1669786f0b3ce82e005debc53218825d537841c8 /auth/cli-editor/src/main | |
parent | 6d72a4a1e5d8678ecd8b093480ea9543089015b0 (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 'auth/cli-editor/src/main')
3 files changed, 14 insertions, 6 deletions
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCommandLineEditorMain.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCommandLineEditorMain.java index 0df8ac629..b632514a5 100644 --- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCommandLineEditorMain.java +++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCommandLineEditorMain.java @@ -104,8 +104,7 @@ public class ApexCommandLineEditorMain { parameters.getApexPropertiesStream()); } catch (final Exception e) { LOGGER.error("start of Apex command line editor failed, error reading Apex model properties from " - + parameters.getApexPropertiesLocation()); - LOGGER.error(e.getMessage()); + + parameters.getApexPropertiesLocation(), e); errorCount++; return; } @@ -160,7 +159,7 @@ public class ApexCommandLineEditorMain { errorCount); } } catch (final IOException e) { - LOGGER.error("execution of Apex command line editor failed: " + e.getMessage()); + LOGGER.error("execution of Apex command line editor failed: " + e.getMessage(), e); } } diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelHandler.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelHandler.java index 2e1a4732b..3d14a83f4 100644 --- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelHandler.java +++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelHandler.java @@ -132,7 +132,7 @@ public class ApexModelHandler { + "\" not found for command \"" + command.getName() + "\""); } catch (final ClassNotFoundException e) { throw new CommandLineException("specified class \"" + command.getApiMethod() + "\" not found for command \"" - + command.getName() + "\""); + + command.getName() + "\"", e); } } @@ -163,7 +163,7 @@ public class ApexModelHandler { } } catch (final Exception e) { throw new CommandLineException("number of argument mismatch on method \"" + command.getApiMethod() - + "\" for command \"" + command.getName() + "\""); + + "\" for command \"" + command.getName() + "\"", e); } return parameterArray; diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorLoop.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorLoop.java index 513f31e67..4f0aeb58b 100644 --- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorLoop.java +++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorLoop.java @@ -43,6 +43,8 @@ import org.onap.policy.apex.model.modelapi.ApexApiResult; import org.onap.policy.apex.model.modelapi.ApexApiResult.Result; import org.onap.policy.apex.model.utilities.TextFileUtils; import org.onap.policy.apex.model.utilities.TreeMapUtils; +import org.slf4j.ext.XLogger; +import org.slf4j.ext.XLoggerFactory; /** * This class implements the editor loop, the loop of execution that continuously executes commands until the quit @@ -51,6 +53,9 @@ import org.onap.policy.apex.model.utilities.TreeMapUtils; * @author Liam Fallon (liam.fallon@ericsson.com) */ public class CommandLineEditorLoop { + // Get a reference to the logger + private static final XLogger LOGGER = XLoggerFactory.getXLogger(CommandLineEditorLoop.class); + // Recurring string constants private static final String COMMAND = "command "; @@ -129,6 +134,7 @@ public class CommandLineEditorLoop { catch (final CommandLineException e) { writer.println(e.getMessage()); errorCount++; + LOGGER.debug("command line error", e); continue; } @@ -157,6 +163,7 @@ public class CommandLineEditorLoop { catch (final CommandLineException e) { writer.println(e.getMessage()); errorCount++; + LOGGER.debug("command line error", e); continue; } @@ -197,8 +204,10 @@ public class CommandLineEditorLoop { catch (final CommandLineException e) { writer.println(e.getMessage()); errorCount++; + LOGGER.debug("command line error", e); } catch (final Exception e) { e.printStackTrace(writer); + LOGGER.error("command line error", e); } } @@ -255,7 +264,7 @@ public class CommandLineEditorLoop { final KeywordNode searchKeywordNode = keywordNodeDeque.peek(); // We have got to the arguments, time to stop looking - if (commandWords.get(i).indexOf('=') > 0) { + if (commandWords.get(i).indexOf('=') >= 0) { unwindStack(startKeywordNode); throw new CommandLineException("command not found: " + stringAL2String(commandWords)); } |