diff options
author | 2018-03-16 16:57:50 +0800 | |
---|---|---|
committer | 2018-03-16 17:05:25 +0800 | |
commit | 30407b138dbb273071c00c85481fd59cb3987633 (patch) | |
tree | eddb830878caab93b4df8651c9487b47d4b68623 /engine-d/src/main/java | |
parent | 2504d624b6c65ee919db506f870ee17b31e51f90 (diff) |
Fix the Sonar Findings
Issue-ID: HOLMES-121
Change-Id: I0b6b0fc81c3f55f21fac28ddedb6d255c2ab663a
Signed-off-by: Shiwei Tian <tian.shiwei@zte.com.cn>
Diffstat (limited to 'engine-d/src/main/java')
-rw-r--r-- | engine-d/src/main/java/org/onap/holmes/engine/dmaap/DMaaPAlarmPolling.java | 3 | ||||
-rw-r--r-- | engine-d/src/main/java/org/onap/holmes/engine/dmaap/SubscriberAction.java | 12 |
2 files changed, 7 insertions, 8 deletions
diff --git a/engine-d/src/main/java/org/onap/holmes/engine/dmaap/DMaaPAlarmPolling.java b/engine-d/src/main/java/org/onap/holmes/engine/dmaap/DMaaPAlarmPolling.java index 862895b..935d2c8 100644 --- a/engine-d/src/main/java/org/onap/holmes/engine/dmaap/DMaaPAlarmPolling.java +++ b/engine-d/src/main/java/org/onap/holmes/engine/dmaap/DMaaPAlarmPolling.java @@ -14,9 +14,6 @@ * limitations under the License. */ package org.onap.holmes.engine.dmaap; - -import static jdk.nashorn.internal.runtime.regexp.joni.Config.log; - import java.util.ArrayList; import java.util.List; import lombok.extern.slf4j.Slf4j; diff --git a/engine-d/src/main/java/org/onap/holmes/engine/dmaap/SubscriberAction.java b/engine-d/src/main/java/org/onap/holmes/engine/dmaap/SubscriberAction.java index 12edc99..c2fa5b8 100644 --- a/engine-d/src/main/java/org/onap/holmes/engine/dmaap/SubscriberAction.java +++ b/engine-d/src/main/java/org/onap/holmes/engine/dmaap/SubscriberAction.java @@ -35,19 +35,21 @@ public class SubscriberAction { private HashMap<String, DMaaPAlarmPolling> pollingTasks = new HashMap<>(); public synchronized void addSubscriber(Subscriber subscriber) { - if (!pollingTasks.containsKey(subscriber.getTopic())) { + String topic = subscriber.getTopic(); + if (topic != null && !pollingTasks.containsKey(topic)) { DMaaPAlarmPolling pollingTask = new DMaaPAlarmPolling(subscriber, droolsEngine); Thread thread = new Thread(pollingTask); thread.start(); - pollingTasks.put(subscriber.getTopic(), pollingTask); + pollingTasks.put(topic, pollingTask); log.info("Subscribe to topic: " + subscriber.getUrl()); } } public synchronized void removeSubscriber(Subscriber subscriber) { - if (pollingTasks.containsKey(subscriber.getTopic())) { - pollingTasks.get(subscriber.getTopic()).stopTask(); - pollingTasks.remove(subscriber.getTopic()); + String topic = subscriber.getTopic(); + if (topic != null && pollingTasks.containsKey(topic)) { + pollingTasks.get(topic).stopTask(); + pollingTasks.remove(topic); } log.info("Topic unsubscribed: " + subscriber.getUrl()); } |