Skip to content


Subversion checkout URL

You can clone with
Download ZIP


exception type should be parametric #6

zdila opened this Issue · 1 comment

2 participants

public final <T> T execute(RetryCallback<T> retryCallback) throws Exception

should be changed to

public final <T, E extends Exception> T execute(RetryCallback<T, E> retryCallback) throws E

This would allow to use RuntimeException as type argument and so not forcing checked exceptions to be handled.


It's a bit late for that I think (would break backwards compatibility), and I'm not sure it would be easy anyway. If you have a proposed change, make sure it works with pre-compiled code against an older spring-retry.

@dsyer dsyer closed this issue from a commit
@dsyer dsyer Parameterize exception type in RetryCallback
So RetryCallback<T, E extends Throwable> and the E parameter appears
in RetryOperations too, making it possible to call it with an unchecked
exception type in the parameter and not catch exceptions.

Users should beware: it's just syntactic sugar, and the actual runtime
type of the exception is never checked at runtime. So, for instance,
declaring a RetryCallback<Object,IllegalArgumentException> doesn't
mean that other Exceptions won't be retried, just that you won't be
able to explicitly throw them if they are checked.

A project using Spring Batch 2.2 was used to test that this works
with user code that uses a library compiled agains Spring Retry 1.0.

Fixes gh-6
@dsyer dsyer closed this in 5fc484d
@dsyer dsyer added this to the 1.1.0 milestone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.