You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2021/05/20 15:24:35 UTC

[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #6950: Fix NPE issue when consumed kafka message is null or the record value is null

Jackie-Jiang commented on a change in pull request #6950:
URL: https://github.com/apache/incubator-pinot/pull/6950#discussion_r636209942



##########
File path: pinot-plugins/pinot-stream-ingestion/pinot-kafka-2.0/src/main/java/org/apache/pinot/plugin/stream/kafka20/KafkaMessageBatch.java
##########
@@ -26,14 +26,26 @@
 import org.apache.pinot.spi.stream.LongMsgOffset;
 import org.apache.pinot.spi.stream.MessageBatch;
 import org.apache.pinot.spi.stream.StreamPartitionMsgOffset;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 public class KafkaMessageBatch implements MessageBatch<byte[]> {
+  private static final Logger LOGGER = LoggerFactory.getLogger(KafkaMessageBatch.class);
 
   private List<MessageAndOffset> messageList = new ArrayList<>();
 
   public KafkaMessageBatch(Iterable<ConsumerRecord<String, Bytes>> iterable) {
     for (ConsumerRecord<String, Bytes> record : iterable) {
+      if (record == null || record.value() == null) {
+        if (record == null) {
+          LOGGER.warn("Consumed record is null, skipping it");
+        } else {
+          LOGGER.warn("Consumed record value is null, offset: {}, skippint it", record.offset());

Review comment:
       ```suggestion
             LOGGER.warn("Consumed record value is null, offset: {}, skipping it", record.offset());
   ```

##########
File path: pinot-plugins/pinot-stream-ingestion/pinot-kafka-2.0/src/main/java/org/apache/pinot/plugin/stream/kafka20/KafkaMessageBatch.java
##########
@@ -26,14 +26,26 @@
 import org.apache.pinot.spi.stream.LongMsgOffset;
 import org.apache.pinot.spi.stream.MessageBatch;
 import org.apache.pinot.spi.stream.StreamPartitionMsgOffset;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 public class KafkaMessageBatch implements MessageBatch<byte[]> {
+  private static final Logger LOGGER = LoggerFactory.getLogger(KafkaMessageBatch.class);
 
   private List<MessageAndOffset> messageList = new ArrayList<>();
 
   public KafkaMessageBatch(Iterable<ConsumerRecord<String, Bytes>> iterable) {
     for (ConsumerRecord<String, Bytes> record : iterable) {
+      if (record == null || record.value() == null) {
+        if (record == null) {
+          LOGGER.warn("Consumed record is null, skipping it");
+        } else {
+          LOGGER.warn("Consumed record value is null, offset: {}, skippint it", record.offset());
+        }
+        continue;
+      }
+      System.out.println("record = " + record);

Review comment:
       Critical: remove




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org