[前][次][番号順一覧][スレッド一覧]

ruby-changes:48080

From: mame <ko1@a...>
Date: Tue, 17 Oct 2017 16:41:09 +0900 (JST)
Subject: [ruby-changes:48080] mame:r60194 (trunk): Suppress leak of file descriptors

mame	2017-10-17 16:41:03 +0900 (Tue, 17 Oct 2017)

  New Revision: 60194

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60194

  Log:
    Suppress leak of file descriptors
    
    `Bundler.ui=` in `Gem::TestCase#setup` creates `Bundler::UI::RGProxy`
    which inherites `::Gem::SilentUI` whose `initialize` opens `/dev/null`,
    and assigns it to `Gem::DefaultUserInteraction.ui`.
    After that, `Gem::TestCase#setup` forces to overwrite
    `Gem::DefaultUserInteraction.ui` with a mock.
    Thus, the instance of `::Gem::SilentUI` is not closed, which leads to
    the leak.
    
    This commit keeps `Gem::DefaultUserInteraction.ui` and manually close it
    in `teardown`.

  Modified files:
    trunk/lib/rubygems/test_case.rb
Index: lib/rubygems/test_case.rb
===================================================================
--- lib/rubygems/test_case.rb	(revision 60193)
+++ lib/rubygems/test_case.rb	(revision 60194)
@@ -236,6 +236,7 @@ class Gem::TestCase < MiniTest::Unit::Te https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L236
     @fetcher     = nil
 
     Bundler.ui                     = Bundler::UI::Silent.new
+    @back_ui                       = Gem::DefaultUserInteraction.ui
     @ui                            = Gem::MockGemUi.new
     # This needs to be a new instance since we call use_ui(@ui) when we want to
     # capture output
@@ -420,6 +421,8 @@ class Gem::TestCase < MiniTest::Unit::Te https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L421
     Gem::Specification._clear_load_cache
     Gem::Specification.unresolved_deps.clear
     Gem::refresh
+
+    @back_ui.close
   end
 
   def common_installer_setup

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]