Skip to content

Commit

Permalink
Fix AS::MessagePack with ENV["RAILS_MAX_THREADS"]
Browse files Browse the repository at this point in the history
`ENV` values are strings, so `ENV["RAILS_MAX_THREADS"]` must be parsed
as an int.

Unfortunately, `MessagePack::Factory::Pool::MemberPool` does not expose
a method to check its member count, so the most we can assert is that
roundtripping works as expected.

Fixes #49446.
  • Loading branch information
jonathanhefner committed Oct 1, 2023
1 parent a5f113f commit bb8ad69
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Expand Up @@ -51,7 +51,7 @@ def message_pack_pool
install_unregistered_type_handler
message_pack_factory.freeze
end
message_pack_factory.pool(ENV.fetch("RAILS_MAX_THREADS") { 5 })
message_pack_factory.pool(ENV.fetch("RAILS_MAX_THREADS", 5).to_i)
end
end

Expand Down
9 changes: 9 additions & 0 deletions activesupport/test/message_pack/shared_serializer_tests.rb
Expand Up @@ -140,6 +140,15 @@ module MessagePackSharedSerializerTests
test "roundtrips ActiveSupport::HashWithIndifferentAccess" do
assert_roundtrip ActiveSupport::HashWithIndifferentAccess.new(a: true, b: 2, c: "three")
end

test "works with ENV['RAILS_MAX_THREADS']" do
original_env = ENV.to_h
ENV["RAILS_MAX_THREADS"] = "1"

assert_roundtrip "value"
ensure
ENV.replace(original_env)
end
end

private
Expand Down

0 comments on commit bb8ad69

Please sign in to comment.