Skip to content

Commit

Permalink
Merge pull request #11780 from thedarkone/logger-naked-rescue-fix
Browse files Browse the repository at this point in the history
Rack::Logger naked rescue fix
  • Loading branch information
guilleiguaran committed Aug 6, 2013
2 parents 48e3c46 + a0907bb commit b7f2ccd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion railties/lib/rails/rack/logger.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def call_app(request, env)
resp = @app.call(env) resp = @app.call(env)
resp[2] = ::Rack::BodyProxy.new(resp[2]) { finish(request) } resp[2] = ::Rack::BodyProxy.new(resp[2]) { finish(request) }
resp resp
rescue rescue Exception
finish(request) finish(request)
raise raise
ensure ensure
Expand Down
8 changes: 6 additions & 2 deletions railties/test/rack_logger_test.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'abstract_unit'
require 'active_support/testing/autorun' require 'active_support/testing/autorun'
require 'active_support/test_case' require 'active_support/test_case'
require 'rails/rack/logger' require 'rails/rack/logger'
Expand Down Expand Up @@ -56,11 +57,14 @@ def test_notification
end end


def test_notification_on_raise 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.starts.length') do
assert_difference('subscriber.finishes.length') do assert_difference('subscriber.finishes.length') do
assert_raises(RuntimeError) do assert_raises(NotImplementedError) do
logger.call 'REQUEST_METHOD' => 'GET' logger.call 'REQUEST_METHOD' => 'GET'
end end
end end
Expand Down

0 comments on commit b7f2ccd

Please sign in to comment.