diff --git a/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb b/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb index 0d66b3f66..4b8f722ee 100644 --- a/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +++ b/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb @@ -779,13 +779,15 @@ module ActiveRecord if RUBY_ENGINE == "jruby" require "jruby" - class org.jruby::RubyObjectSpace::WeakMap - field_reader :map - end + unless ObjectSpace::WeakMap.new.respond_to? :values + class org.jruby::RubyObjectSpace::WeakMap + field_reader :map + end - class ObjectSpace::WeakMap - def values - JRuby.ref(self).map.values.reject(&:nil?) + class ObjectSpace::WeakMap + def values + JRuby.ref(self).map.values.reject(&:nil?) + end + end end - end end