Copilot commented on code in PR #1424:
URL: https://github.com/apache/pulsar-client-go/pull/1424#discussion_r2375272603
##########
pulsar/consumer_zero_queue.go:
##########
@@ -142,11 +146,14 @@ func (z *zeroQueueConsumer) Ack(m Message) error {
func (z *zeroQueueConsumer) checkMsgIDPartition(msgID MessageID) error {
partition := msgID.PartitionIdx()
- if partition != 0 {
- z.log.Errorf("invalid partition index %d expected a partition
equal to 0",
- partition)
- return fmt.Errorf("invalid partition index %d expected a
partition equal to 0",
- partition)
+ if partition == 0 || partition == -1 {
+ return nil
+ }
+ if partition != z.pc.partitionIdx {
+ z.log.Errorf("invalid partition index %d expected a partition
equal to %d",
+ partition, z.pc.partitionIdx)
+ return fmt.Errorf("invalid partition index %d expected a
partition equal to %d",
+ partition, z.pc.partitionIdx)
}
return nil
Review Comment:
The logic for handling partition index 0 has changed unexpectedly.
Previously, partition 0 was the expected partition, but now it's treated as a
special case that always returns nil. This could allow messages from partition
0 to be processed even when the consumer is configured for a different
partition.
```suggestion
if partition == -1 || partition == z.pc.partitionIdx {
return nil
}
z.log.Errorf("invalid partition index %d expected a partition equal to
%d",
partition, z.pc.partitionIdx)
return fmt.Errorf("invalid partition index %d expected a partition
equal to %d",
partition, z.pc.partitionIdx)
```
--
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]