From f36a53d03821624d30b3e91a7a75307b06e3a03c Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 12 Nov 2019 15:44:19 +0900 Subject: Only enabled mon_owned condition with Ruby 2.5+ --- lib/rubygems/core_ext/kernel_require.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib/rubygems/core_ext') diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb index d2bcc508e5..76165a6c90 100644 --- a/lib/rubygems/core_ext/kernel_require.rb +++ b/lib/rubygems/core_ext/kernel_require.rb @@ -32,7 +32,9 @@ module Kernel # that file has already been loaded is preserved. def require(path) - monitor_owned = RUBYGEMS_ACTIVATION_MONITOR.mon_owned? + if RUBYGEMS_ACTIVATION_MONITOR.respond_to?(:mon_owned?) + monitor_owned = RUBYGEMS_ACTIVATION_MONITOR.mon_owned? + end RUBYGEMS_ACTIVATION_MONITOR.enter path = path.to_path if path.respond_to? :to_path @@ -167,9 +169,11 @@ module Kernel raise load_error ensure - if monitor_owned != (ow = RUBYGEMS_ACTIVATION_MONITOR.mon_owned?) - STDERR.puts [$$, Thread.current, $!, $!.backtrace].inspect if $! - raise "CRITICAL: RUBYGEMS_ACTIVATION_MONITOR.owned?: before #{monitor_owned} -> after #{ow}" + if RUBYGEMS_ACTIVATION_MONITOR.respond_to?(:mon_owned?) + if monitor_owned != (ow = RUBYGEMS_ACTIVATION_MONITOR.mon_owned?) + STDERR.puts [$$, Thread.current, $!, $!.backtrace].inspect if $! + raise "CRITICAL: RUBYGEMS_ACTIVATION_MONITOR.owned?: before #{monitor_owned} -> after #{ow}" + end end end -- cgit v1.2.3