You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "danny0405 (via GitHub)" <gi...@apache.org> on 2023/08/18 01:26:20 UTC

[GitHub] [hudi] danny0405 commented on a diff in pull request #9459: [HUDI-6683][FOLLOW-UP] Json & Avro Kafka Source Minor Refactor & Added null Kafka Key test cases

danny0405 commented on code in PR #9459:
URL: https://github.com/apache/hudi/pull/9459#discussion_r1297894861


##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/sources/helpers/KafkaOffsetGen.java:
##########
@@ -479,4 +479,19 @@ private Map<TopicPartition, Long> getGroupOffsets(KafkaConsumer consumer, Set<To
     }
     return fromOffsets;
   }
+
+  /**
+   * get null safe kafka key from kafka key object
+   * @param kafkaKeyObject kafka key object
+   * @return kafka key
+   */
+  public static String getKafkaKey(Object kafkaKeyObject) {
+    String recordKey = null;
+    try {
+      recordKey = kafkaKeyObject.toString();
+    } catch (NullPointerException npe) {

Review Comment:
   Why not just decide whether the `kafkaKeyObject` is null first?



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org

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