1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Marshal arguments to avoid worker mutation, fixes #1452

This commit is contained in:
Mike Perham 2014-01-27 20:29:19 -08:00
parent f58b6926b8
commit 3a6cadce49

View file

@ -131,13 +131,11 @@ module Sidekiq
# Singleton classes are not clonable. # Singleton classes are not clonable.
SINGLETON_CLASSES = [ NilClass, TrueClass, FalseClass, Symbol, Fixnum, Float, Bignum ].freeze SINGLETON_CLASSES = [ NilClass, TrueClass, FalseClass, Symbol, Fixnum, Float, Bignum ].freeze
# Clone the arguments passed to the worker so that if # Deep clone the arguments passed to the worker so that if
# the message fails, what is pushed back onto Redis hasn't # the message fails, what is pushed back onto Redis hasn't
# been mutated by the worker. # been mutated by the worker.
def cloned(ary) def cloned(ary)
ary.map do |val| Marshal.load(Marshal.dump(ary))
SINGLETON_CLASSES.include?(val.class) ? val : val.clone
end
end end
end end
end end