diff options
author | Jim Hahn <jrh3@att.com> | 2021-08-26 14:36:35 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2021-08-26 15:12:19 -0400 |
commit | d04af420514c9c852af77780f0bd5ee23ebb401a (patch) | |
tree | 4212f3e411714770bd4bae3ecb25634190868b13 /feature-pooling-dmaap/src/main | |
parent | 9869e3a9665c0215dc9f9724fe3b5576c0479157 (diff) |
Fix sonars in drools-pdp
Fixed sonars:
- use "var"
- override "equals"
- unused imports
Also changed some of the JPA queries to make them typed queries.
Issue-ID: POLICY-3289
Change-Id: Ib3a00be322d8d00ba492673708439cacfe2c7fc4
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'feature-pooling-dmaap/src/main')
6 files changed, 11 insertions, 12 deletions
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java index ca7b6e26..5c61fb85 100644 --- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java +++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java @@ -138,12 +138,12 @@ public class PoolingFeature implements PolicyEngineFeatureApi, PolicyControllerF String name = controller.getName(); - SpecProperties specProps = new SpecProperties(PoolingProperties.PREFIX, name, featProps); + var specProps = new SpecProperties(PoolingProperties.PREFIX, name, featProps); if (FeatureEnabledChecker.isFeatureEnabled(specProps, PoolingProperties.FEATURE_ENABLED)) { try { // get & validate the properties - PoolingProperties props = new PoolingProperties(name, featProps); + var props = new PoolingProperties(name, featProps); logger.info("pooling enabled for {}", name); ctlr2pool.computeIfAbsent(name, xxx -> makeManager(host, controller, props, activeLatch)); diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java index 769e703e..a50997c2 100644 --- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java +++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java @@ -22,7 +22,6 @@ package org.onap.policy.drools.pooling; import com.google.gson.JsonParseException; import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledThreadPoolExecutor; @@ -516,7 +515,7 @@ public class PoolingManagerImpl implements PoolingManager, TopicListener { msg.checkValidity(); - Method meth = current.getClass().getMethod("process", msg.getClass()); + var meth = current.getClass().getMethod("process", msg.getClass()); changeState((State) meth.invoke(current, msg)); } catch (JsonParseException e) { diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/BucketAssignments.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/BucketAssignments.java index d559a6d6..584edcec 100644 --- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/BucketAssignments.java +++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/BucketAssignments.java @@ -172,7 +172,7 @@ public class BucketAssignments { throw new PoolingFeatureException("too many hosts in message bucket assignments"); } - for (int x = 0; x < hostArray.length; ++x) { + for (var x = 0; x < hostArray.length; ++x) { if (hostArray[x] == null) { throw new PoolingFeatureException("bucket " + x + " has no assignment"); } @@ -181,8 +181,8 @@ public class BucketAssignments { @Override public int hashCode() { - final int prime = 31; - int result = 1; + final var prime = 31; + var result = 1; result = prime * result + Arrays.hashCode(hostArray); return result; } diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ActiveState.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ActiveState.java index 9726c721..a53e7572 100644 --- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ActiveState.java +++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ActiveState.java @@ -176,7 +176,7 @@ public class ActiveState extends ProcessingState { * Generates a heart beat for this host and its successor. */ private void genHeartbeat() { - Heartbeat msg = makeHeartbeat(System.currentTimeMillis()); + var msg = makeHeartbeat(System.currentTimeMillis()); publish(getHost(), msg); if (succHost != null) { diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ProcessingState.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ProcessingState.java index 02d5ab62..8bbb6ad8 100644 --- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ProcessingState.java +++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ProcessingState.java @@ -124,7 +124,7 @@ public class ProcessingState extends State { throw new IllegalArgumentException(newLeader + " cannot replace " + alive.first()); } - Leader msg = makeLeader(alive); + var msg = makeLeader(alive); logger.info("{}/{} hosts have an assignment", msg.getAssignments().getAllHosts().size(), alive.size()); publish(msg); @@ -193,7 +193,7 @@ public class ProcessingState extends State { return new String[BucketAssignments.MAX_BUCKETS]; } - String[] newArray = new String[oldArray.length]; + var newArray = new String[oldArray.length]; System.arraycopy(oldArray, 0, newArray, 0, oldArray.length); return newArray; @@ -231,7 +231,7 @@ public class ProcessingState extends State { private void addIndicesToHostBuckets(String[] bucket2host, Map<String, HostBucket> host2data) { LinkedList<Integer> nullBuckets = new LinkedList<>(); - for (int x = 0; x < bucket2host.length; ++x) { + for (var x = 0; x < bucket2host.length; ++x) { String host = bucket2host[x]; if (host == null) { nullBuckets.add(x); diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/StartState.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/StartState.java index 59bc4fd4..c582d6e0 100644 --- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/StartState.java +++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/StartState.java @@ -55,7 +55,7 @@ public class StartState extends State { super.start(); - Heartbeat hb = makeHeartbeat(hbTimestampMs); + var hb = makeHeartbeat(hbTimestampMs); publish(getHost(), hb); /* |