Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

AD::Routing::Mapper#apply_common_behavior_for: Hash modification during iteration

#5420

The following code fails on JRuby and is bad style and unreliable in general:

options.each do |k,v|
  (options[:constraints] ||= {})[k] = options.delete(k) if options[k].is_a?(Regexp)
end

The failure is as shown in JRuby's CI build:

http://ci.jruby.org/view/Rails/job/rails-master-actionpack-jruby/23...

/Users/nicksieger/Projects/ruby/rails/actionpack/lib/action_dispatch/routing/mapper.rb:778:in `apply_common_behavior_for': can't add a new key into hash during iteration (RuntimeError)
    from /Users/nicksieger/Projects/ruby/rails/actionpack/lib/action_dispatch/routing/mapper.rb:777:in `each'
    from /Users/nicksieger/Projects/ruby/rails/actionpack/lib/action_dispatch/routing/mapper.rb:777:in `apply_common_behavior_for'
    from /Users/nicksieger/Projects/ruby/rails/actionpack/lib/action_dispatch/routing/mapper.rb:602:in `resources'
    from ./test/dispatch/routing_test.rb:229
    from /Users/nicksieger/Projects/ruby/rails/actionpack/lib/action_dispatch/routing/mapper.rb:357:in `scope'
    from ./test/dispatch/routing_test.rb:228
    from /Users/nicksieger/Projects/ruby/rails/actionpack/lib/action_dispatch/routing/mapper.rb:376:in `namespace'
    from /Users/nicksieger/Projects/ruby/rails/actionpack/lib/action_dispatch/routing/mapper.rb:357:in `scope'
     ... 14 levels...
    from /Users/nicksieger/.rvm/gems/jruby-head@rails-test/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
    from /Users/nicksieger/.rvm/gems/jruby-head@rails-test/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each'
    from /Users/nicksieger/.rvm/gems/jruby-head@rails-test/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5

Patch attached.

Reported by Nick Sieger · August 20th, 2010 @ 09:56 PM

State: committed
Milestone: none
Assigned to: nobody
Importance: Low