summaryrefslogtreecommitdiffstats
path: root/model/policy-model/src/main/java
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 /model/policy-model/src/main/java
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 'model/policy-model/src/main/java')
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java8
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java13
2 files changed, 14 insertions, 7 deletions
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java
index 99642d1ae..ad86fb42c 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java
@@ -271,11 +271,11 @@ public class AxLogic extends AxConcept {
"logic flavour is not defined"));
}
- try {
- Assertions.validateStringParameter(LOGIC_FLAVOUR_TOKEN, logicFlavour, LOGIC_FLAVOUR_REGEXP);
- } catch (final IllegalArgumentException e) {
+ String flavourValidationString = Assertions.getStringParameterValidationMessage(LOGIC_FLAVOUR_TOKEN,
+ logicFlavour, LOGIC_FLAVOUR_REGEXP);
+ if (flavourValidationString != null) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "logic flavour invalid-" + e.getMessage()));
+ "logic flavour invalid-" + flavourValidationString));
}
if (logic.replaceAll(WHITESPACE_REGEXP, "").length() == 0) {
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java
index a03b49f13..3c43c6edd 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java
@@ -49,6 +49,8 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
import org.onap.policy.apex.model.utilities.Assertions;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
/**
* This class holds the definition of an Apex policy. A policy is made up of a tree of states, each represented by an
@@ -88,6 +90,9 @@ import org.onap.policy.apex.model.utilities.Assertions;
public class AxPolicy extends AxConcept {
private static final long serialVersionUID = -1775614096390365941L;
+ // Logger for this class
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(AxPolicy.class);
+
@EmbeddedId
@XmlElement(name = "policyKey", required = true)
private AxArtifactKey key;
@@ -364,7 +369,7 @@ public class AxPolicy extends AxConcept {
*/
private AxValidationResult validateStateTree(AxValidationResult result) {
try {
- // Cpnstructor validates policy state tree
+ // Constructor validates policy state tree
AxStateTree policyStateTree = getStateTree();
// Check for unused states
@@ -378,8 +383,10 @@ public class AxPolicy extends AxConcept {
+ " is not referenced in the policy execution tree"));
}
} catch (PolicyRuntimeException pre) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.WARNING,
- "state tree in policy is invalid"));
+ AxValidationMessage validationMessage = new AxValidationMessage(key, this.getClass(),
+ ValidationResult.WARNING, "state tree in policy is invalid");
+ LOGGER.trace(validationMessage.getMessage(), pre);
+ result.addValidationMessage(validationMessage);
}
return result;