Instance variables don't survive Marshal.dump/load round-trip under some 
circumstances.
---------------------------------------------------------------------------------------

                 Key: JRUBY-4442
                 URL: http://jira.codehaus.org/browse/JRUBY-4442
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.4, JRuby 1.5
         Environment: Windows Vista 32-bit
            Reporter: Matjaz Gregoric
         Attachments: fix_marshal_load_bug.diff

Marshal.load doesn't load instance variables correctly under some circumstances.
This was noticed while encountering problems with Rails' sessions (see 
http://jira.codehaus.org/browse/JRUBY-3530).

I wrote a rubyspec to cover this issue (http://rubyspec.org/issues/show/189):

{code:title=load_spec.rb}
it "preserves hash ivars when hash contains a string having ivar" do
  s = 'string'
  s.instance_variable_set :@string_ivar, 'string ivar'
  h = { :key => s }
  h.instance_variable_set :@hash_ivar, 'hash ivar'

  unmarshalled = Marshal.load Marshal.dump(h)
  unmarshalled.instance_variable_get(:@hash_ivar).should == 'hash ivar'  # -> 
returns nil in jruby
  unmarshalled[:key].instance_variable_get(:@string_ivar).should == 'string 
ivar'
end
{code}

Attached patch fixes this issue.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to