Skip to content

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

@mensfeld

Description

@mensfeld

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]

Activity

9mm

9mm commented on Feb 24, 2023

@9mm

Yikes this will teach me to update minor libs before deploying

eregon

eregon commented on Feb 24, 2023

@eregon
Collaborator

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

misdoro

misdoro commented on Feb 24, 2023

@misdoro

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)
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[/+] on Feb 24, 2023
eregon

eregon commented on Feb 24, 2023

@eregon
Collaborator
self-assigned this
on Feb 24, 2023
mensfeld

mensfeld commented on Feb 24, 2023

@mensfeld
Author

Thank you for such fast turnaround!

nijikon

nijikon commented on Feb 25, 2023

@nijikon

That was super quick, thanks!

jcoyne

jcoyne commented on Feb 28, 2023

@jcoyne

Thank you for the fix. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @dentarg@jcoyne@nijikon@eregon@misdoro

      Issue actions

        The Concurrent::Map default_proc is passed a Concurrent::Hash instead of the Concurrent::Map · Issue #993 · ruby-concurrency/concurrent-ruby