mirror of
https://github.com/redis/go-redis.git
synced 2025-07-29 17:41:15 +03:00
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.
This commit is contained in:
@ -426,6 +426,14 @@ func NewFailoverClient(failoverOpt *FailoverOptions) *Client {
|
||||
}
|
||||
rdb.init()
|
||||
|
||||
// Initialize push notification processor to prevent nil pointer dereference
|
||||
if opt.PushNotificationProcessor != nil {
|
||||
rdb.pushProcessor = opt.PushNotificationProcessor
|
||||
} else {
|
||||
// Create void processor for failover client (typically doesn't need push notifications)
|
||||
rdb.pushProcessor = NewVoidPushNotificationProcessor()
|
||||
}
|
||||
|
||||
connPool = newConnPool(opt, rdb.dialHook)
|
||||
rdb.connPool = connPool
|
||||
rdb.onClose = rdb.wrappedOnClose(failover.Close)
|
||||
|
Reference in New Issue
Block a user