From f8850506d05b3d3cdf9f0e0b57ab72f431cb0a83 Mon Sep 17 00:00:00 2001 From: Thomas Poignant Date: Thu, 29 Dec 2022 13:51:15 +0100 Subject: [PATCH] Fix race condition when closing not using the singleton (#435) --- feature_flag.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature_flag.go b/feature_flag.go index 077d1a1c827..3781f6de08b 100644 --- a/feature_flag.go +++ b/feature_flag.go @@ -33,6 +33,7 @@ func Init(config Config) error { // Close the component by stopping the background refresh and clean the cache. func Close() { + onceFF = sync.Once{} ff.Close() } @@ -102,7 +103,6 @@ func New(config Config) (*GoFeatureFlag, error) { // Close wait until thread are done func (g *GoFeatureFlag) Close() { - onceFF = sync.Once{} if g != nil { if g.cache != nil { // clear the cache