diff --git a/pulsar/producer_partition.go b/pulsar/producer_partition.go index 720c7df485..f7f31f27b3 100755 --- a/pulsar/producer_partition.go +++ b/pulsar/producer_partition.go @@ -867,6 +867,13 @@ type pendingItem struct { } func (p *partitionProducer) internalFlushCurrentBatch() { + if p.batchBuilder == nil { + // batch is not enabled + // the batch flush ticker should be stopped but it might still called once + // depends on when stop() is called concurrently + // so we add check to prevent the flow continues on a nil batchBuilder + return + } if p.batchBuilder.IsMultiBatches() { p.internalFlushCurrentBatches() return