Permalink
Browse files

block should not be called if IOError raised

Signed-off-by: Konstantin Haase <konstantin.mailinglists@googlemail.com>
  • Loading branch information...
1 parent dbb7298 commit be6e4180008313f5885a245481faab097d100566 @janx janx committed with rkh Jun 14, 2011
Showing with 8 additions and 5 deletions.
  1. +6 −4 lib/rack/body_proxy.rb
  2. +2 −1 test/spec_body_proxy.rb
View
@@ -10,10 +10,12 @@ def respond_to?(*args)
def close
raise IOError, "closed stream" if @closed
- @body.close if @body.respond_to? :close
- ensure
- @block.call
- @closed = true
+ begin
+ @body.close if @body.respond_to? :close
+ ensure
+ @block.call
+ @closed = true
+ end
end
def closed?
View
@@ -33,7 +33,8 @@
end
should 'not close more than one time' do
- proxy = Rack::BodyProxy.new([]) { }
+ count = 0
+ proxy = Rack::BodyProxy.new([]) { count += 1; raise "Block invoked more than 1 time!" if count > 1 }
proxy.close
lambda {
proxy.close

0 comments on commit be6e418

Please sign in to comment.