Skip to content

Commit a64593d

Browse files
committed
Fix test
1 parent 02a3535 commit a64593d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

pulsar/producer_partition.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,9 @@ func (i *pendingItem) done(err error) {
17371737

17381738
i.isDone = true
17391739
// return the buffer to the pool after all callbacks have been called.
1740-
defer i.buffer.Release()
1740+
if i.buffer != nil {
1741+
defer i.buffer.Release()
1742+
}
17411743
if i.flushCallback != nil {
17421744
i.flushCallback(err)
17431745
}

pulsar/producer_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2383,7 +2383,9 @@ func TestFailPendingMessageWithClose(t *testing.T) {
23832383
})
23842384
}
23852385
partitionProducerImp := testProducer.(*producer).producers[0].(*partitionProducer)
2386-
partitionProducerImp.pendingQueue.Put(&pendingItem{})
2386+
partitionProducerImp.pendingQueue.Put(&pendingItem{
2387+
buffer: buffersPool.GetBuffer(0),
2388+
})
23872389
testProducer.Close()
23882390
assert.Equal(t, 0, partitionProducerImp.pendingQueue.Size())
23892391
}

0 commit comments

Comments
 (0)