Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mensfeld opened this issue Feb 24, 2023 · 8 comments
Assignees

Comments

@mensfeld
Copy link

mensfeld commented Feb 24, 2023

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
Copy link

9mm commented Feb 24, 2023

Yikes this will teach me to update minor libs before deploying

@eregon
Copy link
Collaborator

eregon commented Feb 24, 2023

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

@misdoro
Copy link

misdoro commented Feb 24, 2023

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 added a commit to eregon/concurrent-ruby that referenced this issue Feb 24, 2023
@eregon eregon closed this as completed in f2985bd Feb 24, 2023
@eregon eregon changed the title undefined method `compute_if_absent' for {}:Concurrent::Hash (NoMethodError) The Concurrent::Map default_proc is passed a Concurrent::Hash instead of the Concurrent::Map Feb 24, 2023
@eregon
Copy link
Collaborator

eregon commented Feb 24, 2023

@eregon eregon self-assigned this Feb 24, 2023
@mensfeld
Copy link
Author

Thank you for such fast turnaround!

@nijikon
Copy link

nijikon commented Feb 25, 2023

That was super quick, thanks!

@jcoyne
Copy link

jcoyne commented Feb 28, 2023

Thank you for the fix. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants