summaryrefslogtreecommitdiffstats
path: root/feature-server-pool
diff options
context:
space:
mode:
authorTaka Cho <takamune.cho@att.com>2020-06-23 16:19:35 -0400
committerTakamune Cho <takamune.cho@att.com>2020-06-26 13:02:42 +0000
commit7707b8db05c1018c6a9e53dc0d9126698b88e62d (patch)
tree048aef401f451db0fd03ff007a6c3b03c7b13a44 /feature-server-pool
parenta8cdf564ed34a2ec155a7c5f34392130f36ce877 (diff)
feature server Keyword sonar fix
- remove unnecessary cast - A "NullPointerException" could be thrown; "last" is nullable here - regexp method name - remove curly braces and 'return' Issue-ID: POLICY-2616 Change-Id: Icd6ab0cf1f77cdc8cf1bffb3ae2781702add9ab5 Signed-off-by: Taka Cho <takamune.cho@att.com>
Diffstat (limited to 'feature-server-pool')
-rw-r--r--feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/Keyword.java25
1 files changed, 15 insertions, 10 deletions
diff --git a/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/Keyword.java b/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/Keyword.java
index 10210ebf..c9f4c782 100644
--- a/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/Keyword.java
+++ b/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/Keyword.java
@@ -49,7 +49,7 @@ public class Keyword {
new ConcurrentHashMap<>();
// this is a pre-defined 'Lookup' instance that always returns 'null'
- private static Lookup nullLookup = (Object obj) -> (String) null;
+ private static Lookup nullLookup = (Object obj) -> null;
/**
* This method takes the object's class, looks it up in the 'classToLookup'
@@ -166,14 +166,14 @@ public class Keyword {
}
}
- Class<?> keyClass = buildReflectiveLookup_findKeyClass(clazz);
+ Class<?> keyClass = buildReflectiveLookupFindKeyClass(clazz);
if (keyClass == null) {
// no matching class name found
return null;
}
- return buildReflectiveLookup_build(clazz, keyClass);
+ return buildReflectiveLookupBuild(clazz, keyClass);
}
/**
@@ -182,7 +182,7 @@ public class Keyword {
* interfaces. If no match is found, repeat with the superclass,
* and all the way up the superclass chain.
*/
- private static Class<?> buildReflectiveLookup_findKeyClass(Class<?> clazz) {
+ private static Class<?> buildReflectiveLookupFindKeyClass(Class<?> clazz) {
Class<?> keyClass = null;
for (Class<?> cl = clazz; cl != null; cl = cl.getSuperclass()) {
if (classNameToSequence.containsKey(cl.getName())) {
@@ -212,7 +212,7 @@ public class Keyword {
return keyClass;
}
- private static Lookup buildReflectiveLookup_build(Class<?> clazz, Class<?> keyClass) {
+ private static Lookup buildReflectiveLookupBuild(Class<?> clazz, Class<?> keyClass) {
// we found a matching key in the table -- now, process the values
Class<?> currentClass = keyClass;
@@ -279,7 +279,12 @@ public class Keyword {
}
// add optional conversion function ('null' if it doesn't exist)
- last.next = conversionFunctionLookup;
+ // The preceding 'sequence.split(...)' will always return at
+ // least one entry, so there will be at least one
+ // attempt to go through the loop. If it then makes it out of the loop
+ // without returning (or an exception), 'current' and 'last' will both be
+ // set to non-null values.
+ last.next = conversionFunctionLookup; // NOSONAR
// successful - return the first 'Lookup' instance in the chain
return first;
@@ -441,11 +446,11 @@ public class Keyword {
static final int UUID_LENGTH = 36;
static {
- conversionFunction.put("uuid", value -> {
+ conversionFunction.put("uuid", value ->
// truncate strings to 36 characters
- return value != null && value.length() > UUID_LENGTH
- ? value.substring(0, UUID_LENGTH) : value;
- });
+ value != null && value.length() > UUID_LENGTH
+ ? value.substring(0, UUID_LENGTH) : value
+ );
}
/**