tomstepp commented on code in PR #33596:
URL: https://github.com/apache/beam/pull/33596#discussion_r1929191476


##########
sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/KafkaUnboundedReader.java:
##########
@@ -299,6 +299,29 @@ public Instant getCurrentTimestamp() throws 
NoSuchElementException {
     return curTimestamp;
   }
 
+  @Override
+  public byte[] getCurrentRecordId() throws NoSuchElementException {
+    if (!this.offsetBasedDeduplicationSupported) {
+      throw new RuntimeException("UnboundedSource must enable offset-based 
deduplication.");
+    }
+    if (curRecord != null) {
+      return KafkaIOUtils.OffsetBasedDeduplication.getUniqueId(
+          curRecord.getTopic(), curRecord.getPartition(), 
curRecord.getOffset());

Review Comment:
   Hm, I'm confused by the error (despite null check beforehand) and proper way 
to handle it. Is it due to accessing curRecord multiple times with only one 
null check? The error occurs on 2nd and 3rd ref, but not the 1st.
   
   
/Users/runner/work/beam/beam/sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/KafkaUnboundedReader.java:309:
 error: [dereference.of.nullable] dereference of possibly-null reference 
curRecord
   > Task :sdks:java:io:kafka:compileJava
             curRecord.getTopic(), curRecord.getPartition(), 
curRecord.getOffset());



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to