Skip to content

Commit

Permalink
Make cache and values fully thread-safe
Browse files Browse the repository at this point in the history
Not locking the default initialization can lead to race-conditions.

ref: ruby-concurrency/concurrent-ruby#970
Co-authored-by: Maciej Mensfeld <maciej@mensfeld.pl>
resolves puppetlabs#8951
  • Loading branch information
joshcooper committed Nov 16, 2023
1 parent d3caef9 commit bdbd841
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/puppet/settings.rb
Expand Up @@ -146,8 +146,8 @@ 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 }
@cache = Concurrent::Hash.new { |hash, key| hash.compute_if_absent(key) { Concurrent::Hash.new } }
@values = Concurrent::Hash.new { |hash, key| hash.compute_if_absent(key) { Concurrent::Hash.new } }

# The list of sections we've used.
@used = []
Expand Down

0 comments on commit bdbd841

Please sign in to comment.