From 39b382cf78c9981a1b6f44537d2f2200fb555270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Barri=C3=A9?= Date: Tue, 27 Jul 2021 10:30:34 +0200 Subject: [PATCH] Remove leak when using CurrentAttributes in thread variables The test for CurrentAttributes using thread-local variables leaks an instance in Thread.current. Usually instances are reset in the test helper but the objects remain: activesupport/lib/active_support/current_attributes/test_helper.rb:11 In this situation we use clear_all to make sure we don't leave instances behind when the configuration is changed. --- activesupport/lib/active_support/current_attributes.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/activesupport/lib/active_support/current_attributes.rb b/activesupport/lib/active_support/current_attributes.rb index 64f3d51114..cad0f6b81b 100644 --- a/activesupport/lib/active_support/current_attributes.rb +++ b/activesupport/lib/active_support/current_attributes.rb @@ -144,6 +144,7 @@ module ActiveSupport end def _use_thread_variables=(value) # :nodoc: + clear_all @@use_thread_variables = value end @@use_thread_variables = false