Skip to content

Commit

Permalink
Fix nil pointer dereference in matching (#6543)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaddoll authored Dec 5, 2024
1 parent 2b4a714 commit 3579d66
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion service/matching/tasklist/task_list_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,12 @@ func NewManager(
}
numReadPartitionsFn := func(cfg *config.TaskListConfig) int {
if cfg.EnableGetNumberOfPartitionsFromCache() {
return int(tlMgr.TaskListPartitionConfig().NumReadPartitions)
partitionConfig := tlMgr.TaskListPartitionConfig()
r := 1
if partitionConfig != nil {
r = int(partitionConfig.NumReadPartitions)
}
return r
}
return cfg.NumReadPartitions()
}
Expand Down
8 changes: 8 additions & 0 deletions service/matching/tasklist/task_list_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1518,3 +1518,11 @@ func TestDispatchTask(t *testing.T) {
})
}
}

func TestGetNumPartitions(t *testing.T) {
tlID, err := NewIdentifier("domain-id", "tl", persistence.TaskListTypeDecision)
require.NoError(t, err)
tlm, deps := setupMocksForTaskListManager(t, tlID, types.TaskListKindNormal)
require.NoError(t, deps.dynamicClient.UpdateValue(dynamicconfig.MatchingEnableGetNumberOfPartitionsFromCache, true))
assert.NotPanics(t, func() { tlm.matcher.UpdateRatelimit(common.Ptr(float64(100))) })
}

0 comments on commit 3579d66

Please sign in to comment.