fix (concurrency): prevent concurrent map writes

when booting up, we have a lot of Set in the Config alongside a lot of
Get, Let's block all the concurrent Set
This commit is contained in:
Mickael Kerjean 2022-09-01 23:28:29 +10:00
parent 231e5ba18d
commit bb9fb89d44

View file

@ -461,11 +461,11 @@ func (this *Configuration) Default(value interface{}) *Configuration {
}
func (this *Configuration) Set(value interface{}) *Configuration {
this.mu.Lock()
if this.currentElement == nil {
return this
}
this.mu.Lock()
this.cache.Clear()
if this.currentElement.Value != value {
this.currentElement.Value = value