Skip to content

Commit 9326de2

Browse files
committed
add rollbacks to auth constructors
1 parent dd30004 commit 9326de2

3 files changed

Lines changed: 4 additions & 1 deletion

File tree

auth/basic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ func NewBasicFileAuth(param_url *url.URL, logger *clog.CondLogger) (*BasicAuth,
6363
if reloadInterval > 0 {
6464
go auth.reloadLoop(reloadInterval)
6565
}
66-
6766
if nextAuth := values.Get("else"); nextAuth != "" {
6867
nap, err := NewAuth(nextAuth, logger)
6968
if err != nil {
69+
defer auth.Close()
7070
return nil, fmt.Errorf("chained auth provider construction failed: %w", err)
7171
}
7272
auth.next = nap

auth/cert.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,15 @@ func NewCertAuth(param_url *url.URL, logger *clog.CondLogger) (*CertAuth, error)
6868
if nextAuth := values.Get("next"); nextAuth != "" {
6969
nap, err := NewAuth(nextAuth, logger)
7070
if err != nil {
71+
defer auth.Close()
7172
return nil, fmt.Errorf("chained auth provider construction failed: %w", err)
7273
}
7374
auth.next = nap
7475
}
7576
if nextAuth := values.Get("else"); nextAuth != "" {
7677
nap, err := NewAuth(nextAuth, logger)
7778
if err != nil {
79+
defer auth.Close()
7880
return nil, fmt.Errorf("chained auth provider construction failed: %w", err)
7981
}
8082
auth.reject = nap

auth/redis.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func NewRedisAuth(param_url *url.URL, cluster bool, logger *clog.CondLogger) (*R
5858
if nextAuth := values.Get("else"); nextAuth != "" {
5959
nap, err := NewAuth(nextAuth, logger)
6060
if err != nil {
61+
defer auth.Close()
6162
return nil, fmt.Errorf("chained auth provider construction failed: %w", err)
6263
}
6364
auth.next = nap

0 commit comments

Comments
 (0)