apache/pulsar-client-go

ackReq Variable Assignment in Code

zhangweiii opened this issue · 1 comments

var ackReq *ackRequest
if withResponse {
ackReq := pc.sendCumulativeAck(msgIDToAck)
<-ackReq.doneCh
} else {
pc.ackGroupingTracker.addCumulative(msgIDToAck)
}
pc.options.interceptors.OnAcknowledge(pc.parentConsumer, msgID)
if cmid, ok := msgID.(*chunkMessageID); ok {
pc.unAckChunksTracker.remove(cmid)
}
if ackReq == nil {
return nil
}
return ackReq.err

Hi, I noticed an issue in the code at line 733 where ackReq is assigned using :=, which creates a new variable. This results in ackReq always being nil, and consequently, the code at line 748 never gets executed. Shouldn't the check for ackReq.Err be placed after line 743 instead? OR use = instead :=

@zhangweiii Thank you for the feedback on this issue.