diff --git a/lib/puppet/settings.rb b/lib/puppet/settings.rb index 7136e742bc1..311e1ac3fb8 100644 --- a/lib/puppet/settings.rb +++ b/lib/puppet/settings.rb @@ -147,8 +147,19 @@ def initialize @configuration_file = nil # And keep a per-environment cache - @cache = Concurrent::Hash.new { |hash, key| hash[key] = Concurrent::Hash.new } - @values = Concurrent::Hash.new { |hash, key| hash[key] = Concurrent::Hash.new } + @mutex = Mutex.new + @cache = Concurrent::Hash.new do |hash, key| + @mutex.synchronize do + break hash[key] if hash.key?(key) + hash[key] = Concurrent::Hash.new + end + end + @values = Concurrent::Hash.new do |hash, key| + @mutex.synchronize do + break hash[key] if hash.key?(key) + hash[key] = Concurrent::Hash.new + end + end # The list of sections we've used. @used = []