summaryrefslogtreecommitdiffstats
path: root/services/services-engine/src/main
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 /services/services-engine/src/main
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 'services/services-engine/src/main')
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java20
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumer.java2
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java2
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexCommandLineArguments.java2
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerParameters.java11
5 files changed, 26 insertions, 11 deletions
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java
index 8c7911bce..5a0d11d4c 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java
@@ -26,8 +26,8 @@ import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The Class ApexEvent is an event class that external systems use to send events to and receive
@@ -37,12 +37,13 @@ import org.slf4j.ext.XLoggerFactory;
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class ApexEvent extends HashMap<String, Object> implements Serializable {
- // Recurring string constants
- private static final String EVENT_PREAMBLE = "event \"";
+ private static final long serialVersionUID = -4451918242101961685L;
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexEvent.class);
+ // Get a reference to the logger
+ private static final Logger LOGGER = LoggerFactory.getLogger(ApexEvent.class);
- private static final long serialVersionUID = -4451918242101961685L;
+ // Recurring string constants
+ private static final String EVENT_PREAMBLE = "event \"";
// Holds the next identifier for event execution.
private static AtomicLong nextExecutionID = new AtomicLong(0L);
@@ -286,6 +287,9 @@ public class ApexEvent extends HashMap<String, Object> implements Serializable {
try {
return super.put(validKey(key), value);
} catch (final ApexEventException e) {
+ if (LOGGER.isTraceEnabled()) {
+ LOGGER.trace("put failed", e);
+ }
return null;
}
}
@@ -303,6 +307,10 @@ public class ApexEvent extends HashMap<String, Object> implements Serializable {
validKey(key);
}
} catch (final ApexEventException e) {
+ if (LOGGER.isTraceEnabled()) {
+ LOGGER.trace("putAll failed", e);
+ }
+
// One of the keys is invalid
return;
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumer.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumer.java
index 8c135f19a..f74751a63 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumer.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumer.java
@@ -110,7 +110,7 @@ public class EventRequestorConsumer implements ApexEventConsumer, Runnable {
} catch (final Exception e) {
final String errorMessage =
"could not queue request \"" + eventObject + "\" on event Requestor consumer (" + this.name + ")";
- LOGGER.warn(errorMessage);
+ LOGGER.warn(errorMessage, e);
throw new ApexEventRuntimeException(errorMessage);
}
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java
index ce511be7f..343ef9ac0 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java
@@ -376,7 +376,7 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
} catch (final Exception e) {
// The element is not a string so throw an error
throw new ApexEventRuntimeException("field \"" + fieldName + "\" with type \""
- + jsonField.getClass().getCanonicalName() + "\" is not a string value");
+ + jsonField.getClass().getCanonicalName() + "\" is not a string value", e);
}
// Is regular expression checking required
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexCommandLineArguments.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexCommandLineArguments.java
index bdbd82dc2..ff0eef7f0 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexCommandLineArguments.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexCommandLineArguments.java
@@ -101,7 +101,7 @@ public class ApexCommandLineArguments {
try {
parse(args);
} catch (final ApexException e) {
- throw new ApexRuntimeException("parse error on Apex parameters");
+ throw new ApexRuntimeException("parse error on Apex parameters", e);
}
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerParameters.java
index afd877fd2..8505127e6 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerParameters.java
@@ -29,6 +29,8 @@ import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParame
import org.onap.policy.common.parameters.GroupValidationResult;
import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.parameters.ValidationStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The parameters for a single event producer, event consumer or synchronous event handler.
@@ -51,6 +53,9 @@ import org.onap.policy.common.parameters.ValidationStatus;
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class EventHandlerParameters implements ParameterGroup {
+ // Get a reference to the logger
+ private static final Logger LOGGER = LoggerFactory.getLogger(EventHandlerParameters.class);
+
private String name = null;
private CarrierTechnologyParameters carrierTechnologyParameters = null;
private EventProtocolParameters eventProtocolParameters = null;
@@ -325,8 +330,9 @@ public class EventHandlerParameters implements ParameterGroup {
try {
Pattern.compile(eventNameFilter);
} catch (final PatternSyntaxException pse) {
- result.setResult("eventNameFilter", ValidationStatus.INVALID,
- "event handler eventNameFilter is not a valid regular expression: " + pse.getMessage());
+ String message = "event handler eventNameFilter is not a valid regular expression: " + pse.getMessage();
+ LOGGER.trace(message, pse);
+ result.setResult("eventNameFilter", ValidationStatus.INVALID, message);
}
}
@@ -380,6 +386,7 @@ public class EventHandlerParameters implements ParameterGroup {
/**
* Get the requestor timeout.
+ *
* @return the requestorTimeout.
*/
public long getRequestorTimeout() {