diff options
author | Nick Howard <ndh@baroquebobcat.com> | 2013-08-19 12:39:40 -0600 |
---|---|---|
committer | Nick Howard <ndh@baroquebobcat.com> | 2013-08-19 12:39:40 -0600 |
commit | dfb923e6e52d1fed768672b5b7e6277a599f136a (patch) | |
tree | 569fcad510dfd2e3efae0e4b849eb3c89ee2cb1d | |
parent | 55360ddf7fd5f3fedc327476bf07aac3ba698e0d (diff) | |
download | rails-dfb923e6e52d1fed768672b5b7e6277a599f136a.tar.gz rails-dfb923e6e52d1fed768672b5b7e6277a599f136a.tar.bz2 rails-dfb923e6e52d1fed768672b5b7e6277a599f136a.zip |
ensure freeze on Thread freezes locals
-rw-r--r-- | activesupport/lib/active_support/core_ext/thread.rb | 5 | ||||
-rw-r--r-- | activesupport/test/core_ext/thread_test.rb | 9 |
2 files changed, 14 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/thread.rb b/activesupport/lib/active_support/core_ext/thread.rb index 878ec73ef0..e80f442973 100644 --- a/activesupport/lib/active_support/core_ext/thread.rb +++ b/activesupport/lib/active_support/core_ext/thread.rb @@ -62,6 +62,11 @@ class Thread _locals.has_key?(key.to_sym) end + def freeze + _locals.freeze + super + end + private def _locals diff --git a/activesupport/test/core_ext/thread_test.rb b/activesupport/test/core_ext/thread_test.rb index 230c1203ad..cf1b48d511 100644 --- a/activesupport/test/core_ext/thread_test.rb +++ b/activesupport/test/core_ext/thread_test.rb @@ -63,6 +63,15 @@ class ThreadExt < ActiveSupport::TestCase end end + def test_thread_variable_frozen_after_set + t = Thread.new { }.join + t.thread_variable_set :foo, "bar" + t.freeze + assert_raises(RuntimeError) do + t.thread_variable_set(:baz, "qux") + end + end + def test_thread_variable_security t = Thread.new { sleep } |