This project is archived and is in readonly mode.
JRuby - FlashHash not saving in session when storing ActiveRecord items
Reported by Jarred Nicholls | November 19th, 2009 @ 05:44 PM
I switched to JRuby and started to experience this issue: I store a very lightweight activerecord object into the flash store sometimes (please hold back the flames, this bug shouldn't occur regardless) when reloading a form after a record fails validation. After the first ActiveRecord object is stored into the flash, I start to receive this error indefinitely (anytime I access the flash):
The error occurred while evaluating nil.[]
C:/jruby-1.4.0/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/flash.rb:111:in
sweep'<br/>
C:/jruby-1.4.0/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/flash.rb:110:in
each'
C:/jruby-1.4.0/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/flash.rb:110:in
sweep'<br/>
C:/jruby-1.4.0/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/flash.rb:164:in
flash'
I looked at that line and it's accessing an instance variable of FlashHash named "@used", which stores all the used flash keys. That instance variable is nil on every request after storing an activerecord object into the flash hash. Now, it might be a session store issue as I am using the cookie store (I haven't tried other stores yet).
I'm thinking maybe JRuby and JRuby-OpenSSL is having problems dealing with serializing and deserializing activerecord objects in the cookie store? Anyone ever ran into this problem? If I delete my session cookie, the problem goes away until the next storage of an activerecord object into the flash.
I was very excited to commit to JRuby for true multithreading, but I will go back to trying to make 1.9 SVN work :-P
Thanks,
Jarred
Comments and changes to this ticket
-
Justin Coyne November 21st, 2009 @ 06:38 PM
Jarred. I'm using Jruby and have had problems with Cookie Store. We're having good luck with ActiveRecord Store and Servlet Session Store (if deploying in a servlet container)
-
Jarred Nicholls November 21st, 2009 @ 09:16 PM
Thanks Justin for sharing. I planned to setup Memcached anyways so maybe I wouldn't have an issue with a memcached session store. I still went back to MRI for now...the amount of memory the JVM instance took up was too high for my current situation (even after adjusting heap and GC gen. sizes).
-
Bryan Larsen December 21st, 2009 @ 08:21 PM
We're running into the same problem here, and it affects both ActiveRecordStore and CookieStore. We can work around it with the attached patch. If we do that, we then run into this JRUBY bug: http://jira.codehaus.org/browse/JRUBY-3664
-
Bryan Larsen December 21st, 2009 @ 08:23 PM
Note that contrary to the title, we are not storing any ActiveRecord items in the session or in the FlashHash.
-
Jarred Nicholls December 21st, 2009 @ 09:10 PM
Yeah, I actually did the same thing as the attached patch, but that opened up many more cans of worms. The fundamental issue is that the flash hash ceases to (de)serialize with certain content in it. I think sticking to primitive types is the only way to be safe.
-
Emrys Ingersoll February 15th, 2010 @ 10:12 PM
I'm also running into this problem using the JavaServletStore from the jruby-rack project as the session_store (Rails 2.3.5, jruby-rack-0.9.5, JRuby 1.4, Java 1.6.0_18 64bit on Linux 64bit). I get the same exception at same line (111) of action_controller/flash.rb
-
Emrys Ingersoll February 16th, 2010 @ 05:06 PM
I just built the current JRuby trunk as of commit 2770c7f5720aa23048fbef93b24140195be240ed and replaced JRuby 1.4 with the trunk version in my aforementioned environment and the problem appears to be solved.
I would, tentatively, label this a JRuby issue and not Rails. Though, confirmation that this works for others would be good to have first.
-
mtyaka May 15th, 2010 @ 08:36 AM
- Tag set to jruby
This was a JRuby issue that was resolved in JRuby 1.5. It was caused by a bug in JRuby's Marshal.load.
See tickets http://jira.codehaus.org/browse/JRUBY-4442 and http://jira.codehaus.org/browse/JRUBY-3530 for more information. This ticket can be closed. -
Rohit Arondekar June 15th, 2010 @ 10:41 AM
- State changed from new to resolved
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>