ruby-concurrency/concurrent-ruby

The Concurrent::Map default_proc is passed a Concurrent::Hash instead of the Concurrent::Map

mensfeld opened this issue ยท 8 comments

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]
9mm commented

Yikes this will teach me to update minor libs before deploying

Sorry about this bug, I'll make a release with the fix ASAP.

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)

Thank you for such fast turnaround!

That was super quick, thanks!

Thank you for the fix. โค๏ธ