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

ruby-changes:70735

From: David <ko1@a...>
Date: Wed, 5 Jan 2022 07:26:05 +0900 (JST)
Subject: [ruby-changes:70735] d1a91076dc (master): [rubygems/rubygems] Fix race conditon on JRuby

https://git.ruby-lang.org/ruby.git/commit/?id=d1a91076dc

From d1a91076dc9fb67c08ac074971a9bdbc0207616a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Sun, 26 Dec 2021 22:08:11 +0100
Subject: [rubygems/rubygems] Fix race conditon on JRuby

On JRuby, sometimes we get the following error in CI when running a
realworld test that checks that `gem install rails` succeeds:

```
ERROR:  While executing gem ... (NoMethodError)
    undefined method `ignored=' for nil:NilClass
	/home/runner/.rubies/jruby-9.3.2.0/lib/ruby/stdlib/rubygems/stub_specification.rb:193:in `to_spec'
	org/jruby/RubyArray.java:2642:in `map'
	/home/runner/.rubies/jruby-9.3.2.0/lib/ruby/stdlib/rubygems/specification.rb:758:in `_all'
	/home/runner/.rubies/jruby-9.3.2.0/lib/ruby/stdlib/rubygems/specification.rb:956:in `each'
	org/jruby/RubyEnumerable.java:1710:in `any?'
	/home/runner/.rubies/jruby-9.3.2.0/lib/ruby/stdlib/rubygems/resolver/activation_request.rb:111:in `installed?'
	/home/runner/.rubies/jruby-9.3.2.0/lib/ruby/stdlib/rubygems/request_set.rb:173:in `block in install'
```

I'm not sure how this error is happening, but I think there's no need to
copy the `@ignored` instance variable when materializing stub
specifications. This instance variable is used to not print a warning
about missing extensions more than once for each gem upon gem
activation, but as far as I can see, it's only used by methods that work
on specification stubs. Once specifications are materialized, I think
it can be safely ignored.

https://github.com/rubygems/rubygems/commit/301cecd5a7
---
 lib/rubygems/stub_specification.rb           |  3 ---
 test/rubygems/test_gem_stub_specification.rb | 16 ----------------
 2 files changed, 19 deletions(-)

diff --git a/lib/rubygems/stub_specification.rb b/lib/rubygems/stub_specification.rb
index 47fe7da695b..ac7fc6109a8 100644
--- a/lib/rubygems/stub_specification.rb
+++ b/lib/rubygems/stub_specification.rb
@@ -190,9 +190,6 @@ class Gem::StubSpecification < Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/stub_specification.rb#L190
               end
 
     @spec ||= Gem::Specification.load(loaded_from)
-    @spec.ignored = @ignored if @spec
-
-    @spec
   end
 
   ##
diff --git a/test/rubygems/test_gem_stub_specification.rb b/test/rubygems/test_gem_stub_specification.rb
index e008391ef72..e01d5cad8c1 100644
--- a/test/rubygems/test_gem_stub_specification.rb
+++ b/test/rubygems/test_gem_stub_specification.rb
@@ -180,22 +180,6 @@ class TestStubSpecification < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_stub_specification.rb#L180
     assert bar.to_spec
   end
 
-  def test_to_spec_activated
-    assert @foo.to_spec.is_a?(Gem::Specification)
-    assert_equal "foo", @foo.to_spec.name
-    refute @foo.to_spec.instance_variable_get :@ignored
-  end
-
-  def test_to_spec_missing_extensions
-    stub = stub_with_extension
-
-    capture_output do
-      stub.contains_requirable_file? 'nonexistent'
-    end
-
-    assert stub.to_spec.instance_variable_get :@ignored
-  end
-
   def stub_with_version
     spec = File.join @gemhome, 'specifications', 'stub_e-2.gemspec'
     File.open spec, 'w' do |io|
-- 
cgit v1.2.1


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

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