Skip to content

Commit f305cff

Browse files
zeripath6543
andauthored
Prevent race in PersistableChannelUniqueQueue.Has (#14651) (#14676)
Backport #14651 There is potentially a race with a slow starting internal queue causing a NPE if Has is checked before the internal queue has been setup. This PR adds a lock on the Has() fn. Fix #14311 Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: 6543 <[email protected]>
1 parent c032006 commit f305cff

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

modules/queue/unique_queue_disk_channel.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ func (q *PersistableChannelUniqueQueue) Has(data Data) (bool, error) {
149149
if err != nil || has {
150150
return has, err
151151
}
152+
q.lock.Lock()
153+
defer q.lock.Unlock()
154+
if q.internal == nil {
155+
return false, nil
156+
}
152157
return q.internal.(UniqueQueue).Has(data)
153158
}
154159

0 commit comments

Comments
 (0)