summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBundlerbot <bot@bundler.io>2020-01-13 16:45:55 +0000
committerBundlerbot <bot@bundler.io>2020-01-13 16:45:55 +0000
commit6346c036a12cbae94c02bacb08c81a8fc5302238 (patch)
tree6beaf50a525af01f91c8f6eb2418be83c86ffda5
parentcb96a16c9b7ffbb50c9929be7058ab1f4a552ca3 (diff)
parent104dbfbb1dd8fa2b32fe117c1ae1e4203e0665fe (diff)
downloadbundler-6346c036a12cbae94c02bacb08c81a8fc5302238.tar.gz
Merge #7569
7569: Load `CompactIndexClient` upfront during specs r=deivid-rodriguez a=deivid-rodriguez Thanks so much for the contribution! To make reviewing this PR a bit easier, please fill out answers to the following questions. ### What was the end-user problem that led to this PR? The problem was failing CI: https://github.com/rubygems/bundler/runs/386607433. ### What was your diagnosis of the problem? My diagnosis was that it could be caused by autoloading not being thread safe. The `CompactIndexClient` constant is autoloaded. If two parallel threads try to autoload the constant at the same time, it could happen that one of them sees the constant in an incomplete state (no `initialize` method defined yet). ### What is your fix for the problem, implemented in this PR? My fix is to load the constant upfront. ### Why did you choose this fix out of the possible options? I chose this fix because even if I could stop autoloading the constant, I don't want to touch code in `lib` at the moment just to fix a testing issue. Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
-rw-r--r--spec/bundler/fetcher/compact_index_spec.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/spec/bundler/fetcher/compact_index_spec.rb b/spec/bundler/fetcher/compact_index_spec.rb
index c9419d3eb1..b00eadceab 100644
--- a/spec/bundler/fetcher/compact_index_spec.rb
+++ b/spec/bundler/fetcher/compact_index_spec.rb
@@ -1,5 +1,8 @@
# frozen_string_literal: true
+# load CompactIndexClient upfront to prevent thread safety issues during parallel specs
+require "bundler/compact_index_client"
+
RSpec.describe Bundler::Fetcher::CompactIndex do
let(:downloader) { double(:downloader) }
let(:display_uri) { Bundler::URI("http://sampleuri.com") }