aboutsummaryrefslogtreecommitdiffstats
path: root/model/utilities
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/utilities
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/utilities')
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/Assertions.java15
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/typeutils/ClassBuilder.java9
2 files changed, 21 insertions, 3 deletions
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/Assertions.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/Assertions.java
index a3ecccebe..02a91a72c 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/Assertions.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/Assertions.java
@@ -20,6 +20,9 @@
package org.onap.policy.apex.model.utilities;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
/**
* The Class Assertions is a template class that is used as a shorthand for assertions in the source code.
*
@@ -27,6 +30,9 @@ package org.onap.policy.apex.model.utilities;
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public final class Assertions {
+ // Logger for this class
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(Assertions.class);
+
/**
* Private constructor used to prevent sub class instantiation.
*/
@@ -46,8 +52,13 @@ public final class Assertions {
try {
validateStringParameter(parameterName, parameterValue, pattern);
} catch (IllegalArgumentException e) {
- // This will cause a SONAR error but eliminates all SONAR messages in callers
- return e.getMessage();
+ String message = "parameter " + parameterName + " with value " + parameterValue
+ + " does not match regular expression " + pattern;
+ if (LOGGER.isTraceEnabled()) {
+ LOGGER.trace(message, e);
+ }
+
+ return message;
}
return null;
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/typeutils/ClassBuilder.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/typeutils/ClassBuilder.java
index ffebc405f..2e6e96d0b 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/typeutils/ClassBuilder.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/typeutils/ClassBuilder.java
@@ -24,6 +24,9 @@ import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
//CHECKSTYLE:OFF: checkstyle:IllegalImport
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
//CHECKSTYLE:ON: checkstyle:IllegalImport
@@ -38,6 +41,9 @@ import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
*/
@SuppressWarnings("restriction")
public class ClassBuilder {
+ // Logger for this class
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(ClassBuilder.class);
+
private final Class<?> clazz;
private final List<ClassBuilder> parameters = new ArrayList<>();
@@ -62,7 +68,8 @@ public class ClassBuilder {
} catch (ClassNotFoundException e) {
try {
return new ClassBuilder(Class.forName("java.lang." + className));
- } catch (Exception ignore) {
+ } catch (Exception classFindException) {
+ LOGGER.warn("class nout found", classFindException);
throw new IllegalArgumentException("Class '" + className
+ "' not found. Also looked for a class called 'java.lang." + className + "'", e);
}