nodece commented on code in PR #1494:
URL: https://github.com/apache/pulsar-client-go/pull/1494#discussion_r3231562006
##########
pulsar/consumer_impl.go:
##########
@@ -781,15 +773,22 @@ func (c *consumer) SeekByTime(time time.Time) error {
return errs
}
-func (c *consumer) checkMsgIDPartition(msgID MessageID) error {
+func (c *consumer) findPartitionConsumer(msgID MessageID) (*partitionConsumer,
error) {
+ c.Lock()
+ defer c.Unlock()
+ return c.unsafeFindPartitionConsumer(msgID)
+}
+
+// NOTE: This method must be called when c.Lock is held
+func (c *consumer) unsafeFindPartitionConsumer(msgID MessageID)
(*partitionConsumer, error) {
partition := msgID.PartitionIdx()
if partition < 0 || int(partition) >= len(c.consumers) {
c.log.Errorf("invalid partition index %d expected a partition
between [0-%d]",
partition, len(c.consumers))
- return fmt.Errorf("invalid partition index %d expected a
partition between [0-%d]",
+ return nil, fmt.Errorf("invalid partition index %d expected a
partition between [0-%d]",
partition, len(c.consumers))
}
- return nil
+ return c.consumers[msgID.PartitionIdx()], nil
Review Comment:
I'm concerned that `c.consumers[msgID.PartitionIdx()]` could be `nil`.
--
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]