From e696f4e0828d2f26921e233aeede05c4359770a7 Mon Sep 17 00:00:00 2001 From: Parshad Patel Date: Thu, 6 Sep 2018 17:29:03 +0900 Subject: Fix NPE issue in msgrt Fix NullPointerException related sonar issue Issue-ID: DMAAP-687 Change-Id: I6a2f32398fdef79d0ea5c1abbbe8b3b803873594 Signed-off-by: Parshad Patel --- src/main/java/com/att/dmf/mr/beans/DMaaPKafkaConsumerFactory.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/main/java/com/att/dmf/mr/beans') diff --git a/src/main/java/com/att/dmf/mr/beans/DMaaPKafkaConsumerFactory.java b/src/main/java/com/att/dmf/mr/beans/DMaaPKafkaConsumerFactory.java index e4e09c8..f60fd53 100644 --- a/src/main/java/com/att/dmf/mr/beans/DMaaPKafkaConsumerFactory.java +++ b/src/main/java/com/att/dmf/mr/beans/DMaaPKafkaConsumerFactory.java @@ -185,9 +185,11 @@ public class DMaaPKafkaConsumerFactory implements ConsumerFactory { log.info("Creating Kafka consumer for group [" + consumerGroupName + "], consumer [" + consumerId + "], on topic [" + topic + "]."); - - fCache.signalOwnership(topic, consumerGroupName, consumerId); - + + if (fCache != null) { + fCache.signalOwnership(topic, consumerGroupName, consumerId); + } + final Properties props = createConsumerConfig(topic,consumerGroupName, consumerId); long fCreateTimeMs = System.currentTimeMillis(); KafkaConsumer cc = new KafkaConsumer<>(props); -- cgit 1.2.3-korg