Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Rails 6.1.2.x dynamic finders cause Java::JavaLang::ClassCastException #6563

@ryanfb

Description

@ryanfb

Environment Information

  • JRuby version (jruby -v): jruby 9.2.14.0 (2.5.7) 2020-12-08 ebe64bafb9 Java HotSpot(TM) 64-Bit Server VM 25.45-b02 on 1.8.0_45-b14 +jit [darwin-x86_64]
  • Operating system and platform: initially discovered on MacOS 10.13.6, but replicated on Travis under Ubuntu 18.04.5 LTS (Bionic), see below
  • Application/framework version: Rails 6.1.2.1
  • Code available at: https://github.com/sosol/sosol/tree/rails-6.1.2.1

Expected Behavior

  • Dynamic Rails finder methods e.g. find_by_custom_model_attribute() should continue to work

Actual Behavior

  • Dynamic Rails finder methods result in Java::JavaLang::ClassCastException: org.jruby.ir.operands.TemporaryClosureVariable cannot be cast to org.jruby.ir.operands.DepthCloneable (full backtrace from Travis under OpenJDK 8 attached here)

I was able to isolate this down to dynamic finders by running a single test and adding debug logging until I could pin it down. With e.g. this change to use where instead, the single test I chose passes instead of resulting in Java::JavaLang::ClassCastException (single test invoked with rails test test/unit/publication_test.rb:91).

Exception occurs on both Rails 6.1.2.1 and Rails 6.1.2.

Exception does not occur under Rails 6.1.1 with nothing else changed: https://travis-ci.com/github/sosol/sosol/builds/217275737

I also expanded tests from OpenJDK 8 up through OpenJDK 15 to verify that it's not related to the older JVM with Rails 6.1.2.1: https://travis-ci.com/github/sosol/sosol/builds/217273487

Only difference between the two is the Rails version (+ dependencies): sosol/sosol@rails-6.1.2.1...rails-6.1.1

Please let me know if you think I should file a regression on Rails or whichever action/active* gem change is responsible instead of or in addition to here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions