Skip to content

Commit

Permalink
Don't panic when defer a cache that has failed to init (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaspoignant authored Mar 29, 2021
1 parent c101f1a commit 574f9a6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions feature_flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,14 @@ func New(config Config) (*GoFeatureFlag, error) {

// Close wait until thread are done
func (g *GoFeatureFlag) Close() {
// clear the cache
g.cache.Close()
if g != nil {
if g.cache != nil {
// clear the cache
g.cache.Close()
}

// stop the background updater
g.bgUpdater.close()
g.bgUpdater.close()
}
}

// startFlagUpdaterDaemon is the daemon that refresh the cache every X seconds.
Expand Down

0 comments on commit 574f9a6

Please sign in to comment.