Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect nil handling in workflowTaskPoller #1412

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion internal/internal_task_pollers.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,22 @@ func newWorkflowTaskPoller(
domain string,
params workerExecutionParameters,
) *workflowTaskPoller {
/*
Explicit nil handling is needed here. Otherwise, poller.ldaTunnel would not return a nil result
*/
var ldaTunnelInterface localDispatcher
if ldaTunnel != nil {
ldaTunnelInterface = ldaTunnel
}

return &workflowTaskPoller{
basePoller: basePoller{shutdownC: params.WorkerStopChannel},
service: service,
domain: domain,
taskListName: params.TaskList,
identity: params.Identity,
taskHandler: taskHandler,
ldaTunnel: ldaTunnel,
ldaTunnel: ldaTunnelInterface,
metricsScope: metrics.NewTaggedScope(params.MetricsScope),
logger: params.Logger,
stickyUUID: uuid.New(),
Expand Down
15 changes: 15 additions & 0 deletions internal/internal_task_pollers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ const (
_testIdentity = "test-worker"
)

func Test_newWorkflowTaskPoller(t *testing.T) {
t.Run("success with nil ldaTunnel", func(t *testing.T) {
poller := newWorkflowTaskPoller(
nil,
nil,
nil,
_testDomainName,
workerExecutionParameters{})
assert.NotNil(t, poller)
if poller.ldaTunnel != nil {
t.Error("unexpected not nil ldaTunnel")
}
})
}

func TestLocalActivityPanic(t *testing.T) {
// regression: panics in local activities should not terminate the process
s := WorkflowTestSuite{logger: testlogger.NewZap(t)}
Expand Down
Loading