Skip to content

Commit ad16b21

Browse files
committed
fix: initialize push notification processor in NewFailoverClient
- Add push processor initialization to NewFailoverClient to prevent nil pointer dereference - Use VoidPushNotificationProcessor for failover clients (typically don't need push notifications) - Ensure consistent behavior across all client creation paths including failover scenarios - Complete the coverage of all client types that inherit from baseClient This fixes the final nil pointer dereference that was occurring in failover client contexts where the pushProcessor field was nil, causing segmentation violations during Redis operations in sentinel-managed failover scenarios.
1 parent a2de263 commit ad16b21

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

sentinel.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,14 @@ func NewFailoverClient(failoverOpt *FailoverOptions) *Client {
426426
}
427427
rdb.init()
428428

429+
// Initialize push notification processor to prevent nil pointer dereference
430+
if opt.PushNotificationProcessor != nil {
431+
rdb.pushProcessor = opt.PushNotificationProcessor
432+
} else {
433+
// Create void processor for failover client (typically doesn't need push notifications)
434+
rdb.pushProcessor = NewVoidPushNotificationProcessor()
435+
}
436+
429437
connPool = newConnPool(opt, rdb.dialHook)
430438
rdb.connPool = connPool
431439
rdb.onClose = rdb.wrappedOnClose(failover.Close)

0 commit comments

Comments
 (0)