Skip to content

Commit 269362e

Browse files
authored
Merge pull request #440 from mensfeld/main
Make the yaml cache fully thread-safe
2 parents 2ecffb6 + 0b11bb3 commit 269362e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/dry/schema/messages/yaml.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ def self.flat_hash(hash, path = EMPTY_ARRAY, keys = {})
7070

7171
# @api private
7272
def self.cache
73-
@cache ||= Concurrent::Map.new { |h, k| h[k] = Concurrent::Map.new }
73+
@cache ||= Concurrent::Map.new do |h, k|
74+
h.compute_if_absent(k) { Concurrent::Map.new }
75+
end
7476
end
7577

7678
# @api private

0 commit comments

Comments
 (0)