Fixed potential panic in error handler when Redis is down. (#31643)
This commit is contained in:
@@ -0,0 +1 @@
|
||||
Fixed potential panic in error handler when Redis is down.
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
@@ -208,6 +209,14 @@ func (h *Handler) storeError(ctx context.Context, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// Check if pool is nil to prevent panic
|
||||
if h.pool == nil {
|
||||
if h.testOnStore != nil {
|
||||
h.testOnStore(errors.New("redis pool is nil"))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// not using a connection that follows redirections here
|
||||
// in order to do pipeline commands
|
||||
conn := h.pool.Get()
|
||||
|
||||
Reference in New Issue
Block a user