Permalink
Browse files

ensure freeze on Thread freezes locals

  • Loading branch information...
1 parent 55360dd commit dfb923e6e52d1fed768672b5b7e6277a599f136a @baroquebobcat baroquebobcat committed Aug 19, 2013
Showing with 14 additions and 0 deletions.
  1. +5 −0 activesupport/lib/active_support/core_ext/thread.rb
  2. +9 −0 activesupport/test/core_ext/thread_test.rb
@@ -62,6 +62,11 @@ def thread_variable?(key)
_locals.has_key?(key.to_sym)
end
+ def freeze
+ _locals.freeze
+ super
+ end
+
private
def _locals
@@ -63,6 +63,15 @@ def test_thread_variable_frozen
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 }

0 comments on commit dfb923e

Please sign in to comment.