wolfstudy commented on a change in pull request #65: [Issue 64] fix bug: type
assert cause panic
URL: https://github.com/apache/pulsar-client-go/pull/65#discussion_r334536144
##########
File path: pulsar/impl_partition_producer.go
##########
@@ -293,14 +293,17 @@ func (p *partitionProducer) internalFlushCurrentBatch() {
func (p *partitionProducer) internalFlush(fr *flushRequest) {
p.internalFlushCurrentBatch()
- pi := p.pendingQueue.PeekLast().(*pendingItem)
- pi.sendRequests = append(pi.sendRequests, &sendRequest{
- msg: nil,
- callback: func(id MessageID, message *ProducerMessage, e error)
{
- fr.err = e
- fr.waitGroup.Done()
- },
- })
+ pi, ok := p.pendingQueue.PeekLast().(*pendingItem)
+ if ok {
+ pi.sendRequests = append(pi.sendRequests, &sendRequest{
+ msg: nil,
+ callback: func(id MessageID, message *ProducerMessage,
e error) {
+ fr.err = e
+ fr.waitGroup.Done()
+ },
+ })
+ }
+
Review comment:
If not ok, `fr.waitGroup.Done()` will not be executed, `wg.wait()` in send
will not be released, and sending will be blocked indefinitely
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services