Skip to content

Commit a94ee70

Browse files
alexshtinmeiliang86
authored andcommitted
Call cancel on context to prevent memory leak (#156)
1 parent 7254208 commit a94ee70

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

internal/internal_task_handlers_interfaces_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ func (s *PollLayerInterfacesTestSuite) TearDownTest() {
9696
}
9797

9898
func (s *PollLayerInterfacesTestSuite) TestProcessWorkflowTaskInterface() {
99-
ctx, _ := thrift.NewContext(10)
99+
ctx, cancel := thrift.NewContext(10)
100+
defer cancel()
100101

101102
// mocks
102103
s.service.EXPECT().PollForDecisionTask(gomock.Any(), gomock.Any()).Return(&m.PollForDecisionTaskResponse{}, nil)
@@ -116,7 +117,8 @@ func (s *PollLayerInterfacesTestSuite) TestProcessWorkflowTaskInterface() {
116117
}
117118

118119
func (s *PollLayerInterfacesTestSuite) TestProcessActivityTaskInterface() {
119-
ctx, _ := thrift.NewContext(10)
120+
ctx, cancel := thrift.NewContext(10)
121+
defer cancel()
120122

121123
// mocks
122124
s.service.EXPECT().PollForActivityTask(gomock.Any(), gomock.Any()).Return(&m.PollForActivityTaskResponse{}, nil)

internal/internal_task_pollers.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,8 @@ func (lath *localActivityTaskHandler) executeLocalActivityTask(task *localActivi
527527
}
528528

529529
ctx, cancel := context.WithDeadline(ctx, deadline)
530+
defer cancel()
531+
530532
task.Lock()
531533
if task.canceled {
532534
task.Unlock()

0 commit comments

Comments
 (0)