summaryrefslogtreecommitdiff
path: root/lib/rubygems/core_ext
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2019-11-12 15:44:19 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2019-11-12 19:36:41 +0900
commitf36a53d03821624d30b3e91a7a75307b06e3a03c (patch)
treeee750d6cfcc50f9728ec18f9fe947bae331fd0e8 /lib/rubygems/core_ext
parent3bf8ffad714efa98949e25095f1c5e2844318958 (diff)
Only enabled mon_owned condition with Ruby 2.5+
Diffstat (limited to 'lib/rubygems/core_ext')
-rw-r--r--lib/rubygems/core_ext/kernel_require.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
index d2bcc50..76165a6 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