Skip to content

Commit edd106f

Browse files
nodeceCopilot
andcommitted
fix: avoid context leak in blue-green migration test
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 87ce8f9 commit edd106f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

pulsar/blue_green_migration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ func testTopicMigrate(
162162

163163
for true {
164164
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
165-
defer cancel()
166165
_, err := producer.Send(ctx, &pm)
166+
cancel()
167167
if err == nil {
168168
break
169169
}
@@ -187,8 +187,8 @@ func testTopicMigrate(
187187

188188
for true {
189189
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
190-
defer cancel()
191190
m, err := consumer.Receive(ctx)
191+
cancel()
192192
if err == nil {
193193
err = consumer.Ack(m)
194194
if err == nil {

0 commit comments

Comments
 (0)