From 6a9b54b275feff5369419a86997e94d0a95fc48e Mon Sep 17 00:00:00 2001 From: "waqas.ikram" Date: Thu, 7 Jun 2018 16:01:35 +0100 Subject: Fixing Sonar bugs and Vulnerabilities Change-Id: Id5a95f23f1308dbb9f7f0c0f5567e238ecf830af Issue-ID: POLICY-859 Signed-off-by: waqas.ikram --- .../apex/core/engine/executor/StateOutput.java | 21 +++++++++------------ .../core/engine/executor/context/AxStateFacade.java | 2 +- .../core/engine/executor/context/AxTaskFacade.java | 2 +- .../context/StateFinalizerExecutionContext.java | 2 +- 4 files changed, 12 insertions(+), 15 deletions(-) (limited to 'core/core-engine') diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/StateOutput.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/StateOutput.java index 2274b7c23..aaec71b47 100644 --- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/StateOutput.java +++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/StateOutput.java @@ -34,7 +34,8 @@ import org.onap.policy.apex.model.policymodel.concepts.AxStateOutput; import org.onap.policy.apex.model.utilities.Assertions; /** - * This class is the output of a state, and is used by the engine to decide what the next state for execution is. + * This class is the output of a state, and is used by the engine to decide what the next state for + * execution is. * * @author Liam Fallon (liam.fallon@ericsson.com) */ @@ -115,15 +116,11 @@ public class StateOutput { for (final Entry incomingFieldEntry : eventFieldMap.entrySet()) { final String fieldName = incomingFieldEntry.getKey(); final AxField fieldDef = incomingFieldDefinitionMap.get(fieldName); - try { - - // Check if this field is a field in the event - if (!outputEventDef.getFields().contains(fieldDef)) { - throw new StateMachineException( - "field \"" + fieldName + "\" does not exist on event \"" + outputEventDef.getID() + "\""); - } - } catch (final Exception e) { - e.printStackTrace(); + + // Check if this field is a field in the event + if (!outputEventDef.getFields().contains(fieldDef)) { + throw new StateMachineException( + "field \"" + fieldName + "\" does not exist on event \"" + outputEventDef.getID() + "\""); } // Set the value in the output event @@ -132,8 +129,8 @@ public class StateOutput { } /** - * This method copies any fields that exist on the input event that also exist on the output event if they are not - * set on the output event. + * This method copies any fields that exist on the input event that also exist on the output + * event if they are not set on the output event. * * @param incomingEvent The incoming event to copy from */ diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/AxStateFacade.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/AxStateFacade.java index 226f06ade..80d7e651b 100644 --- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/AxStateFacade.java +++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/AxStateFacade.java @@ -40,7 +40,7 @@ public class AxStateFacade { // CHECKSTYLE:OFF: checkstyle:visibilityModifier Logic has access to this field /** The full definition information for the state. */ - public AxState state; + public final AxState state; // CHECKSTYLE:ON: checkstyle:visibilityModifier diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/AxTaskFacade.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/AxTaskFacade.java index 015f3ae80..85bf96c8d 100644 --- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/AxTaskFacade.java +++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/AxTaskFacade.java @@ -46,7 +46,7 @@ public class AxTaskFacade { * The full definition of the task we are presenting a facade to, executing logic has full access to the task * definition. */ - public AxTask task; + public final AxTask task; // CHECKSTYLE:ON: checkstyle:visibilityModifier diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java index 2e5971142..874d4def1 100644 --- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java +++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java @@ -70,7 +70,7 @@ public class StateFinalizerExecutionContext { * fields to determine what state output to select. Once a state finalizer has selected a state output, it must * marshal these fields so that they match the fields required for the event defined in the state output. */ - public Map fields; + public final Map fields; // A message specified in the logic private String message; -- cgit 1.2.3-korg