spring retry setRetryableExceptions, setFatalExceptions not available

java, spring, spring-retry

Solution

Maybe this can help. You have to create a map holding all retryable exceptions by classtype, and add it to the policy. Probably similar with fatal exceptions.

Map<Class<? extends Throwable>, Boolean> r = new HashMap<>();
r.put(RetryException.class, true);
SimpleRetryPolicy p = new SimpleRetryPolicy(MAX_RETRIES, r);
RetryTemplate t = new RetryTemplate();
t.setRetryPolicy(p);

Problem

According to the spring batch/retry documentation (http://docs.spring.io/spring-batch/reference/html/retry.html) in section 9.2 one can specify which exceptions you would like to retry or not retry on via setRetryableExceptions or setFatalExceptions when using the SimpleRetryPolicy. However, these methods are not defined in the current release (1.0.3) in GitHub https://github.com/spring-projects/spring-retry/blob/master/src/main/java/org/springframework/retry/RetryPolicy.java . So, is this a documentation error? If not, then where are the methods located? From the source code, it seems that only the retryable exceptions can be set via the constructor that takes a Map of exceptions. There doesn't appear to be a way to define the fatal exceptions.

Original source

Related problems