Skip to content

Commit

Permalink
add lock (apache#1304)
Browse files Browse the repository at this point in the history
  • Loading branch information
tylitianrui committed Jul 5, 2021
1 parent 42ef7fe commit a109967
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config/config_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,8 @@ func GetApplicationConfig() *ApplicationConfig {
// if not found, create new one
func GetProviderConfig() ProviderConfig {
if providerConfig == nil {
configAccessMutex.Lock()
defer configAccessMutex.Unlock()
if providerConfig == nil {
return ProviderConfig{}
}
Expand All @@ -465,6 +467,8 @@ func GetProviderConfig() ProviderConfig {
// So you don't need to worry about the race condition
func GetConsumerConfig() ConsumerConfig {
if consumerConfig == nil {
configAccessMutex.Lock()
defer configAccessMutex.Unlock()
if consumerConfig == nil {
return ConsumerConfig{}
}
Expand Down

0 comments on commit a109967

Please sign in to comment.