Skip to content

Commit

Permalink
add lock (apache#1304)
Browse files Browse the repository at this point in the history
  • Loading branch information
tylitianrui authored and Changeden committed Jul 29, 2021
1 parent 2f47462 commit 55d711f
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 @@ -441,6 +441,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 @@ -455,6 +457,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 55d711f

Please sign in to comment.