Skip to content

Commit

Permalink
Fix nil panic (#5153)
Browse files Browse the repository at this point in the history
<!-- Describe what has changed in this PR -->
**What changed?**
Add nil check when using namespaceEntry

<!-- Tell your future self why have you made these changes -->
**Why?**
nil panic found at edge case

<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
**How did you test it?**
n/a

<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
**Potential risks**
no

<!-- Is this PR a hotfix candidate or require that a notification be
sent to the broader community? (Yes/No) -->
**Is hotfix candidate?**
no
  • Loading branch information
xwduan authored and rodrigozhou committed Nov 30, 2023
1 parent db10079 commit 407ff8a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion service/history/replication/raw_task_converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,15 @@ func (c *SourceTaskConverterImpl) Convert(
if clientShardID != c.clientShardKey.ShardID {
return nil, nil
}
var ctx context.Context
var cancel context.CancelFunc

if namespaceEntry != nil {
ctx, cancel = newTaskContext(namespaceEntry.Name().String())
} else {
ctx, cancel = context.WithTimeout(context.Background(), applyReplicationTimeout)
}

ctx, cancel := newTaskContext(namespaceEntry.Name().String())
defer cancel()
replicationTask, err := c.historyEngine.ConvertReplicationTask(ctx, task)
if err != nil {
Expand Down

0 comments on commit 407ff8a

Please sign in to comment.