This is an automated email from the ASF dual-hosted git repository.

shiro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 6e14edc  ARROW-4964: [Ruby] Add closed check if available on auto close
6e14edc is described below

commit 6e14edcca63947d692e2ba0a94fe0704455dd53d
Author: Kouhei Sutou <k...@clear-code.com>
AuthorDate: Wed Mar 20 08:28:03 2019 +0900

    ARROW-4964: [Ruby] Add closed check if available on auto close
    
    Author: Kouhei Sutou <k...@clear-code.com>
    
    Closes #3977 from kou/ruby-check-closed and squashes the following commits:
    
    c4c1359d <Kouhei Sutou>  Add closed check if available on auto close
---
 ruby/red-arrow/lib/arrow/block-closable.rb | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/ruby/red-arrow/lib/arrow/block-closable.rb 
b/ruby/red-arrow/lib/arrow/block-closable.rb
index 473ee14..ec236bd 100644
--- a/ruby/red-arrow/lib/arrow/block-closable.rb
+++ b/ruby/red-arrow/lib/arrow/block-closable.rb
@@ -24,7 +24,11 @@ module Arrow
       begin
         yield(io)
       ensure
-        io.close
+        if io.respond_to?(:closed?)
+          io.close unless io.closed?
+        else
+          io.close
+        end
       end
     end
   end

Reply via email to