From 2646c1021adb181b96395afc92b143e115ff113f Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Fri, 4 Nov 2016 14:00:02 -0500 Subject: Use different name for main and thread connection variable. Under JRuby, the updates of the one shared variable interleaved, causing threads to pick up each others' connections. I'm amazed this worked on MRI. --- activerecord/test/cases/connection_pool_test.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/activerecord/test/cases/connection_pool_test.rb b/activerecord/test/cases/connection_pool_test.rb index d7ff9d6880..3844f1eca2 100644 --- a/activerecord/test/cases/connection_pool_test.rb +++ b/activerecord/test/cases/connection_pool_test.rb @@ -184,14 +184,14 @@ module ActiveRecord def test_checkout_behaviour pool = ConnectionPool.new ActiveRecord::Base.connection_pool.spec - connection = pool.connection - assert_not_nil connection + main_connection = pool.connection + assert_not_nil main_connection threads = [] 4.times do |i| threads << Thread.new(i) do - connection = pool.connection - assert_not_nil connection - connection.close + thread_connection = pool.connection + assert_not_nil thread_connection + thread_connection.close end end -- cgit v1.2.3