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

Handle circular error causes

Shall fix #2284. While checking whether an application error or a
sidekiq shutdown caused the exception, we keep track of the causes that
were already checked. If a cause was already checked, we can stop
because the whole transitive closure of its causes was checked as well.
This commit is contained in:
Eugen Kuksa 2015-04-04 09:27:13 +02:00
parent be7d77d9ed
commit eb2115237d

View file

@ -188,12 +188,16 @@ module Sidekiq
end
end
def exception_caused_by_shutdown?(e)
def exception_caused_by_shutdown?(e, checked_causes = [])
# In Ruby 2.1.0 only, check if exception is a result of shutdown.
return false unless defined?(e.cause)
# Handle circular causes
checked_causes << e.object_id
return false if checked_causes.include?(e.cause.object_id)
e.cause.instance_of?(Sidekiq::Shutdown) ||
exception_caused_by_shutdown?(e.cause)
exception_caused_by_shutdown?(e.cause, checked_causes)
end
end