Overriding Time._dump does not behave the same as MRI
-----------------------------------------------------
Key: JRUBY-2975
URL: http://jira.codehaus.org/browse/JRUBY-2975
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules
Affects Versions: JRuby 1.1.4
Reporter: Thomas E Enebo
Fix For: JRuby 1.1.5
This is generally what Rails is doing to work around a Time bug in MRI (which
we also have). The code in question has a problem because when _original_load
executes it does not end up loading the instance variable
'@marshal_with_utc_coercion'.
{noformat}
require 'pp'
class Time
class << self
alias_method :_original_load, :_load
def _load(marshaled_time)
time = _original_load(marshaled_time)
utc = time.send(:remove_instance_variable, '@marshal_with_utc_coercion')
utc ? time.utc : time
end
end
alias_method :_original_dump, :_dump
def _dump(*args)
obj = self.frozen? ? self.dup : self
obj.instance_variable_set('@marshal_with_utc_coercion', utc?)
obj._original_dump(*args)
end
end
t = Time.local(2000).freeze
pp t
m = Marshal.dump t
pp m
pp t
t2 = Marshal.load(m)
pp t2
{noformat}
--
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