From 30407b138dbb273071c00c85481fd59cb3987633 Mon Sep 17 00:00:00 2001 From: Shiwei Tian Date: Fri, 16 Mar 2018 16:57:50 +0800 Subject: Fix the Sonar Findings Issue-ID: HOLMES-121 Change-Id: I0b6b0fc81c3f55f21fac28ddedb6d255c2ab663a Signed-off-by: Shiwei Tian --- .../java/org/onap/holmes/engine/dmaap/DMaaPAlarmPolling.java | 3 --- .../java/org/onap/holmes/engine/dmaap/SubscriberAction.java | 12 +++++++----- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'engine-d/src/main/java/org') 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 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()); } -- cgit 1.2.3-korg