From 409c004affa30efbbfd384a9cd645f7969ccc11a Mon Sep 17 00:00:00 2001 From: Edouard CHIN Date: Wed, 19 Nov 2025 23:15:41 +0100 Subject: [ruby/rubygems] Make the Bundler logger thread safe: - The Logger is not thread safe when calling `with_level`. This now becomes problematic because we are using multiple threads during the resolution phase in order to fetch git gems. https://github.com/ruby/rubygems/commit/380653ae74 --- spec/bundler/bundler/ui/shell_spec.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'spec') diff --git a/spec/bundler/bundler/ui/shell_spec.rb b/spec/bundler/bundler/ui/shell_spec.rb index 422c850a65..83f147191e 100644 --- a/spec/bundler/bundler/ui/shell_spec.rb +++ b/spec/bundler/bundler/ui/shell_spec.rb @@ -81,4 +81,32 @@ RSpec.describe Bundler::UI::Shell do end end end + + describe "threads" do + it "is thread safe when using with_level" do + stop_thr1 = false + stop_thr2 = false + + expect(subject.level).to eq("debug") + + thr1 = Thread.new do + subject.silence do + sleep(0.1) until stop_thr1 + end + + stop_thr2 = true + end + + thr2 = Thread.new do + subject.silence do + stop_thr1 = true + sleep(0.1) until stop_thr2 + end + end + + [thr1, thr2].each(&:join) + + expect(subject.level).to eq("debug") + end + end end -- cgit v1.2.3