From a0907bbdad0b8cbead9c8d295b9037036ec650d0 Mon Sep 17 00:00:00 2001 From: thedarkone Date: Tue, 6 Aug 2013 17:03:29 +0200 Subject: [PATCH] "Naked" rescue clauses only catch StandardError subclasses. Similar to #11497. --- railties/lib/rails/rack/logger.rb | 2 +- railties/test/rack_logger_test.rb | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/railties/lib/rails/rack/logger.rb b/railties/lib/rails/rack/logger.rb index ad5fdcf648..ef4cdcb080 100644 --- a/railties/lib/rails/rack/logger.rb +++ b/railties/lib/rails/rack/logger.rb @@ -38,7 +38,7 @@ module Rails resp = @app.call(env) resp[2] = ::Rack::BodyProxy.new(resp[2]) { finish(request) } resp - rescue + rescue Exception finish(request) raise ensure diff --git a/railties/test/rack_logger_test.rb b/railties/test/rack_logger_test.rb index 635a8a8865..6ebd47fff9 100644 --- a/railties/test/rack_logger_test.rb +++ b/railties/test/rack_logger_test.rb @@ -57,11 +57,14 @@ module Rails end def test_notification_on_raise - logger = TestLogger.new { raise } + logger = TestLogger.new do + # using an exception class that is not a StandardError subclass on purpose + raise NotImplementedError + end assert_difference('subscriber.starts.length') do assert_difference('subscriber.finishes.length') do - assert_raises(RuntimeError) do + assert_raises(NotImplementedError) do logger.call 'REQUEST_METHOD' => 'GET' end end