Skip to content
This repository has been archived by the owner on Jan 10, 2019. It is now read-only.

Rewrite the isRetryable method so that it is understandable and respe… #128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions aws-flow/lib/aws/decider/async_retrying_executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,21 +125,23 @@ def initialize(retry_function, options)
# otherwise.
#
def isRetryable(failure)
return true if @exceptions_to_exclude.empty? && @exceptions_to_include.empty?

if failure.respond_to?(:cause) && !failure.cause.nil?
failure_class = failure.cause.class
else
failure_class = failure.class
end

return true if @exceptions_to_exclude.empty? && @exceptions_to_include.empty?
raise "#{failure} appears in both exceptions_to_include and exceptions_to_exclude" if @exceptions_to_exclude.include?(failure_class) && @exceptions_to_include.include?(failure_class)
# In short, default to false.
# The second part of the statement does an intersection of the 2 arrays
# to see if any of the ancestors of failure exists in
# @exceptions_to_include
return (!@exceptions_to_exclude.include?(failure_class) && !(@exceptions_to_include & failure_class.ancestors).empty?)
return (!excluded?(failure_class) && included?(failure_class))
end

def excluded?(failure_class)
!(@exceptions_to_exclude & failure_class.ancestors).empty?
end

#return (!@exceptions_to_exclude.include?(failure) && @exceptions_to_include.include?(failure))
def included?(failure_class)
!(@exceptions_to_include & failure_class.ancestors).empty?
end

# Schedules a new retry attempt with an initial delay.
Expand Down