[amber] missing mutex during updateRefreshToken
The config fields require locking.
Test: CQ
Change-Id: Ib9caf6c4d30f71ae5332eebd3f47f05ad2012823
diff --git a/go/src/amber/source/source.go b/go/src/amber/source/source.go
index 2bd566f..dc6edec 100644
--- a/go/src/amber/source/source.go
+++ b/go/src/amber/source/source.go
@@ -559,10 +559,16 @@
// try to start a refresh token update. This should not be called while holding
// the struct mutex as it will be locked during this call
func (f *Source) updateRefreshToken() {
- if !f.Enabled() || f.cfg.Config.Oauth2Config == nil {
+ if !f.Enabled() {
return
}
+ f.mu.Lock()
+ defer f.mu.Unlock()
+
+ if f.cfg.Config.Oauth2Config == nil {
+ return
+ }
go defaultTokenLoader.ReadToken(f.processTokenUpdate, f.cfg.Config.Oauth2Config.ClientId)
}