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:
parent
f58b6926b8
commit
3a6cadce49
1 changed files with 2 additions and 4 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue