lyra icon indicating copy to clipboard operation
lyra copied to clipboard

retryableExceptions configuration and implementation

Open spjoe opened this issue 8 years ago • 3 comments

Most likely https://github.com/jhalterman/lyra/blob/ce347a69357fef1b34e92d92a4f9e68792d81255/src/main/java/net/jodah/lyra/internal/util/Exceptions.java#L46

should be if (retryableExceptions.contains(e.getClass()) || e.getCause() instanceof EOFException) , because retryableExceptions is a set of Classes not a set of exceptions. But actually retryableExceptions.contains(e) can be removed all together, because it is implicit covered by line 44

A more general suggestion of my would be to make recoverable exceptions more configurable. Let users provide predicates if exceptions are recoverable or not, because more often than not you have a whole exception cause chain. And only checking type of the outermost exception does not suffice.

spjoe avatar Dec 07 '17 08:12 spjoe

The API could certainly support a Predicate to determine if a failure should be retryable, and the default predicate could match the retry exceptions list, which the user could still modify. If the user provides there own predicate, it would bypass the default one.

jhalterman avatar Dec 07 '17 20:12 jhalterman

Predicate is a JDK 8 API and Lyra 0.5.x minimum JDK version is 1.6, so this would need to go into a major release, e.g. 1.x.

acogoluegnes avatar Dec 08 '17 08:12 acogoluegnes

@acogoluegnes With 'Predicate' I meant a concept not the concrete jdk impl. So you can invent your own predicate if you like to be java 6 compatible.

spjoe avatar Dec 11 '17 10:12 spjoe