The Concurrent::Map default_proc is passed a Concurrent::Hash instead of the Concurrent::Map
mensfeld opened this issue ยท 8 comments
mensfeld commented
With concurrent-ruby 1.2.0 things work as expected. With 1.2.1 I get following error:
undefined method `compute_if_absent' for {}:Concurrent::Hash (NoMethodError)relevant stacktrace:
gems/concurrent-ruby-1.2.1/lib/concurrent-ruby/concurrent/collection/map/non_concurrent_map_backend.rb:22:in `[]'it's a divination of behaviour of map, working on repro ๐
# Works in 1.2.0 but breaks in 1.2.1
@listeners = Concurrent::Map.new do |h, k|
h.compute_if_absent(k) { Concurrent::Array.new }
end
@listeners[:a]dentarg commented
9mm commented
Yikes this will teach me to update minor libs before deploying
eregon commented
Sorry about this bug, I'll make a release with the fix ASAP.
misdoro commented
Same for fetch_or_store method on the Hash:
NoMethodError: undefined method `fetch_or_store' for {}:Concurrent::Hash
h.fetch_or_store(key, Concurrent::Map.new)
eregon commented
Fixed in f2985bd
Released as https://github.com/ruby-concurrency/concurrent-ruby/releases/tag/v1.2.2
mensfeld commented
Thank you for such fast turnaround!
nijikon commented
That was super quick, thanks!
jcoyne commented
Thank you for the fix. โค๏ธ