Only enabled mon_owned condition with Ruby 2.5+

This commit is contained in:
Hiroshi SHIBATA 2019-11-12 15:44:19 +09:00
parent 3bf8ffad71
commit f36a53d038
No known key found for this signature in database
GPG Key ID: F9CF13417264FAC2

View File

@ -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