Copilot commented on code in PR #1482:
URL: https://github.com/apache/pulsar-client-go/pull/1482#discussion_r3120394700


##########
pulsar/consumer_partition.go:
##########
@@ -1308,10 +1308,25 @@ func (pc *partitionConsumer) MessageReceived(response 
*pb.CommandMessage, header
        )
        for i := 0; i < numMsgs; i++ {
                smm, payload, err := reader.ReadMessage()
-               if err != nil || payload == nil {
+               isNullValue := msgMeta.GetNullValue() || (smm != nil && 
smm.GetNullValue())
+               if err != nil {
+                       // A null-value (tombstone) message has no payload 
bytes on the wire, so
+                       // the non-batched reader returns ErrEOM. Accept it 
instead of discarding
+                       // it as corrupted, matching the Java client's behavior 
for compaction
+                       // tombstones.
+                       if isNullValue && err == internal.ErrEOM {
+                               payload = nil
+                       } else {
+                               pc.discardCorruptedMessage(pbMsgID, 
pb.CommandAck_BatchDeSerializeError)
+                               return err
+                       }

Review Comment:
   When accepting a tombstone with `err == internal.ErrEOM`, the code keeps 
`err` non-nil and continues. It works today because `err` is not used later, 
but it’s easy to misread and could become a latent bug if future logic 
inspects/returns `err` after this block. Consider explicitly setting `err = 
nil` in the tombstone/`ErrEOM` acceptance path to make the intent unambiguous.



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