-
Notifications
You must be signed in to change notification settings - Fork 137
Closed
Description
I don't really have any deep experience with Rack or JRuby Rack - so please excuse the question if it speaks to ignorance.
After upgrading a JRuby-on-Rails application from Rails 6.1.7.6
to 7.0.8
I get the following stack traces when accessing any rails pages/controllers.
NoMethodError in StagesController#overview
undefined method `[]' for nil:NilClass (around line/#86)
def get_servlet_session(env, create = false)
servlet_session = env[ENV_SERVLET_SESSION_KEY] # <--- line 86
invalid = false
begin
if servlet_session.nil? ||
coming from
servlet_session = store.get_servlet_session(@env) |
I'm not quite sure how the @env
ends up nil
, but there seems to be some Rails-version-coupled stuff here.
jruby-rack/src/main/ruby/jruby/rack/session_store.rb
Lines 13 to 58 in 710c1a4
if defined?(::Rack::Session::Abstract::SessionHash) # Rack 1.3+ | |
# as of rails 3.1.x the rack session hash implementation is used | |
# rather than the custom rails AbstractStore::SessionHash class | |
class SessionHash < ::Rack::Session::Abstract::SessionHash; end | |
# 1.5.0 removed SessionHash http://github.com/rack/rack/commit/83a270d64820 | |
OptionsHash = if defined?(::Rack::Session::Abstract::OptionsHash) | |
::Rack::Session::Abstract::OptionsHash | |
else nil | |
end | |
elsif defined?(ActionDispatch::Session::AbstractStore) # Rails 3.0 | |
require 'active_support/core_ext/hash' # non-loaded SessionHash dependency | |
class SessionHash < ActionDispatch::Session::AbstractStore::SessionHash; end | |
OptionsHash = ActionDispatch::Session::AbstractStore::OptionsHash | |
else # a fallback for (old) Rails 2.3 | |
class SessionHash < ActionController::Session::AbstractStore::SessionHash; end | |
OptionsHash = ActionController::Session::AbstractStore::OptionsHash | |
end | |
SessionHash.class_eval do | |
# Allows direct delegation to servlet session methods when session is active | |
def method_missing(method, *args, &block) | |
servlet_session = store.get_servlet_session(@env) | |
if servlet_session && servlet_session.respond_to?(method) | |
servlet_session.send(method, *args, &block) | |
else | |
super | |
end | |
end | |
private | |
def store | |
@store ||= defined?(@store) ? @store : @by # Rack 1.5 renamed @by | |
end | |
end |
Does anyone know what might have changed that could perhaps break rack or jruby-rack to point me in the right direction? Something to do with autoloading?
uri:classloader:/jruby/rack/session_store.rb:86:in `get_servlet_session'
uri:classloader:/jruby/rack/session_store.rb:45:in `method_missing'
actionpack (7.0.8) lib/action_dispatch/middleware/flash.rb:63:in `commit_flash'
actionpack (7.0.8) lib/action_controller/metal.rb:189:in `dispatch'
actionpack (7.0.8) lib/action_controller/metal.rb:251:in `dispatch'
actionpack (7.0.8) lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
actionpack (7.0.8) lib/action_dispatch/routing/route_set.rb:32:in `serve'
actionpack (7.0.8) lib/action_dispatch/journey/router.rb:50:in `block in serve'
org/jruby/RubyArray.java:1989:in `each'
actionpack (7.0.8) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (7.0.8) lib/action_dispatch/routing/route_set.rb:852:in `call'
rack (2.2.8) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.8) lib/rack/etag.rb:27:in `call'
rack (2.2.8) lib/rack/conditional_get.rb:27:in `call'
rack (2.2.8) lib/rack/head.rb:12:in `call'
actionpack (7.0.8) lib/action_dispatch/http/permissions_policy.rb:38:in `call'
actionpack (7.0.8) lib/action_dispatch/http/content_security_policy.rb:36:in `call'
uri:classloader:/jruby/rack/session_store.rb:79:in `context'
rack (2.2.8) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/cookies.rb:704:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (7.0.8) lib/active_support/callbacks.rb:99:in `run_callbacks'
actionpack (7.0.8) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/actionable_exceptions.rb:17:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/debug_exceptions.rb:28:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/show_exceptions.rb:29:in `call'
railties (7.0.8) lib/rails/rack/logger.rb:40:in `call_app'
railties (7.0.8) lib/rails/rack/logger.rb:27:in `call'
sprockets-rails (3.4.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/remote_ip.rb:93:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/request_id.rb:26:in `call'
rack (2.2.8) lib/rack/method_override.rb:24:in `call'
rack (2.2.8) lib/rack/runtime.rb:22:in `call'
activesupport (7.0.8) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/server_timing.rb:61:in `block in call'
actionpack (7.0.8) lib/action_dispatch/middleware/server_timing.rb:26:in `collect_events'
actionpack (7.0.8) lib/action_dispatch/middleware/server_timing.rb:60:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/static.rb:23:in `call'
rack (2.2.8) lib/rack/sendfile.rb:110:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/host_authorization.rb:138:in `call'
railties (7.0.8) lib/rails/engine.rb:530:in `call'
uri:classloader:/rack/handler/servlet.rb:22:in `call'
Metadata
Metadata
Assignees
Labels
No labels