From 638c2327f41997d85d34f9a129a012f5816bba40 Mon Sep 17 00:00:00 2001 From: Chad Wilson Date: Thu, 23 Jan 2025 14:56:55 +0800 Subject: [PATCH] Fix Rails 7.1 compatibility by ensuring active_support is required before railtie Not sure if this is us, strictly speaking but we seem to need to require active_support before the railties or the issue at https://github.com/rails/rails/issues/49495#issuecomment-1749085658 occurs Since we do reference loggers here, seems appropriate for us to require ourselves. --- src/main/ruby/jruby/rack/rails/railtie.rb | 13 ++----------- src/spec/ruby/rails3x/stub/active_support.rb | 9 +++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 src/spec/ruby/rails3x/stub/active_support.rb diff --git a/src/main/ruby/jruby/rack/rails/railtie.rb b/src/main/ruby/jruby/rack/rails/railtie.rb index 1ef002ab..532a04b5 100644 --- a/src/main/ruby/jruby/rack/rails/railtie.rb +++ b/src/main/ruby/jruby/rack/rails/railtie.rb @@ -6,6 +6,7 @@ # See the file LICENSE.txt for details. #++ +require 'active_support' require 'rails/railtie' require 'pathname' @@ -42,17 +43,7 @@ class Railtie < ::Rails::Railtie logger.level = logger.class.const_get(log_level.to_s.upcase) log_formatter = config.log_formatter if config.respond_to?(:log_formatter) # >= 4.0 logger.formatter = log_formatter if log_formatter && logger.respond_to?(:formatter=) - if defined?(ActiveSupport::TaggedLogging) - if ActiveSupport::TaggedLogging.is_a?(Class) # Rails 3.2 - logger = ActiveSupport::TaggedLogging.new(logger) - else # Rails 4.0 - # extends the logger as well as it's logger.formatter instance : - # NOTE: good idea to keep or should we use a clone as Rails.logger ? - #dup_logger = logger.dup - #dup_logger.formatter = logger.formatter.dup - logger = ActiveSupport::TaggedLogging.new(logger) - end - end + logger = ActiveSupport::TaggedLogging.new(logger) logger end end diff --git a/src/spec/ruby/rails3x/stub/active_support.rb b/src/spec/ruby/rails3x/stub/active_support.rb new file mode 100644 index 00000000..3012c894 --- /dev/null +++ b/src/spec/ruby/rails3x/stub/active_support.rb @@ -0,0 +1,9 @@ +#-- +# Copyright (c) 2010-2012 Engine Yard, Inc. +# Copyright (c) 2007-2009 Sun Microsystems, Inc. +# This source code is available under the MIT license. +# See the file LICENSE.txt for details. +#++ + +module ActiveSupport +end \ No newline at end of file