aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorYasuo Honda <yasuo.honda@gmail.com>2017-12-10 23:32:00 +0000
committerYasuo Honda <yasuo.honda@gmail.com>2017-12-13 16:29:03 +0000
commit1d3fe75649e9e5dd9efacb7a6a0d9e9d12b3df34 (patch)
tree1b11b9b733f2897207ca1c01064fd88e76e87e2f /activerecord
parent2fb78dc30528b3a2dcf539ba1d3c77f01f04885e (diff)
downloadrails-1d3fe75649e9e5dd9efacb7a6a0d9e9d12b3df34.tar.gz
rails-1d3fe75649e9e5dd9efacb7a6a0d9e9d12b3df34.tar.bz2
rails-1d3fe75649e9e5dd9efacb7a6a0d9e9d12b3df34.zip
Suppress expected exceptions by `report_on_exception` = `false` in Ruby 2.5
* Ruby 2.4 introduces `report_on_exception` to control if it reports exceptions in thread, this default value has been `false` in Ruby 2.4. Refer https://www.ruby-lang.org/en/news/2016/11/09/ruby-2-4-0-preview3-released/ * Ruby 2.5 changes `report_on_exception` default value to `true` since this commit https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?revision=61183&view=revision This pull request suppresses expected exceptions by setting `report_on_exception` = `false` it also supports Ruby 2.3 which does not have`report_on_exception`.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/adapters/postgresql/transaction_test.rb2
-rw-r--r--activerecord/test/cases/connection_pool_test.rb3
2 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/transaction_test.rb b/activerecord/test/cases/adapters/postgresql/transaction_test.rb
index c24dfeb345..9821b103df 100644
--- a/activerecord/test/cases/adapters/postgresql/transaction_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/transaction_test.rb
@@ -14,6 +14,7 @@ module ActiveRecord
setup do
@abort, Thread.abort_on_exception = Thread.abort_on_exception, false
+ Thread.report_on_exception, @original_report_on_exception = false, Thread.report_on_exception if Thread.respond_to?(:report_on_exception)
@connection = ActiveRecord::Base.connection
@@ -31,6 +32,7 @@ module ActiveRecord
@connection.drop_table "samples", if_exists: true
Thread.abort_on_exception = @abort
+ Thread.report_on_exception = @original_report_on_exception if Thread.respond_to?(:report_on_exception)
end
test "raises SerializationFailure when a serialization failure occurs" do
diff --git a/activerecord/test/cases/connection_pool_test.rb b/activerecord/test/cases/connection_pool_test.rb
index 1e08cc74dc..70c0ffb3bf 100644
--- a/activerecord/test/cases/connection_pool_test.rb
+++ b/activerecord/test/cases/connection_pool_test.rb
@@ -469,6 +469,7 @@ module ActiveRecord
end
def test_non_bang_disconnect_and_clear_reloadable_connections_throw_exception_if_threads_dont_return_their_conns
+ Thread.report_on_exception, original_report_on_exception = false, Thread.report_on_exception if Thread.respond_to?(:report_on_exception)
@pool.checkout_timeout = 0.001 # no need to delay test suite by waiting the whole full default timeout
[:disconnect, :clear_reloadable_connections].each do |group_action_method|
@pool.with_connection do |connection|
@@ -477,6 +478,8 @@ module ActiveRecord
end
end
end
+ ensure
+ Thread.report_on_exception = original_report_on_exception if Thread.respond_to?(:report_on_exception)
end
def test_disconnect_and_clear_reloadable_connections_attempt_to_wait_for_threads_to_return_their_conns