<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -23,6 +23,8 @@ class JRuby::Rack::Response
     b = &quot;&quot;
     @body.each {|part| b &lt;&lt; part }
     b
+  ensure
+    @body.close if @body.respond_to?(:close)
   end
 
   def respond(response)
@@ -75,6 +77,8 @@ class JRuby::Rack::Response
       # HACK: deal with objects that don't comply with Rack specification
       @body = [@body.to_s]
       retry
+    ensure
+      @body.close if @body.respond_to?(:close)
     end
   end
 end</diff>
      <filename>src/main/ruby/jruby/rack/response.rb</filename>
    </modified>
    <modified>
      <diff>@@ -115,4 +115,23 @@ describe JRuby::Rack::Response do
     @response.respond(@servlet_response)
     response.should == @servlet_response
   end
+
+  it &quot;#getBody should call close on the body if the body responds to close&quot; do
+    @body.should_receive(:each).ordered.and_yield &quot;hello&quot;
+    @body.should_receive(:close).ordered
+    @response.getBody.should == &quot;hello&quot;
+  end
+
+  it &quot;#write_body should call close on the body if the body responds to close&quot; do
+    @body.should_receive(:each).ordered.and_return do |block|
+      block.call &quot;hello&quot;
+      block.call &quot;there&quot;
+    end
+    @body.should_receive(:close).ordered
+    stream = mock &quot;output stream&quot;
+    @servlet_response.stub!(:getOutputStream).and_return stream
+    stream.should_receive(:write).exactly(2).times
+
+    @response.write_body(@servlet_response)
+  end
 end</diff>
      <filename>src/spec/ruby/jruby/rack/response_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>e173b4856e47afe2146642164b4eacf0baa52881</id>
    </parent>
  </parents>
  <author>
    <name>Nick Sieger</name>
    <email>nick@nicksieger.com</email>
  </author>
  <url>http://github.com/nicksieger/jruby-rack/commit/61e44e49d11d44c19c75e55d67e0ae6214626b8e</url>
  <id>61e44e49d11d44c19c75e55d67e0ae6214626b8e</id>
  <committed-date>2009-09-20T09:49:53-07:00</committed-date>
  <authored-date>2009-09-20T09:49:53-07:00</authored-date>
  <message>JRUBY_RACK-22: Ensure we call #close on the body per the Rack spec</message>
  <tree>a2eb33f2eed347da1b1d0302c96d1ff8b07955e2</tree>
  <committer>
    <name>Nick Sieger</name>
    <email>nick@nicksieger.com</email>
  </committer>
</commit>
