final RetryInvocation invocation, final RetryDefinition definition,
final List exceptions) throws Throwable {
Throwable lastEx = (Throwable) RetryHandler.getLastFromList(exceptions);
if (tries > 0) {
if (definition.retryOn(lastEx)) {
ArgumentSaver argSaver = definition.getArgumentSaver();
CleanUpContext context = this.cleanUpContextFactory
.createCleanUpContext(invocation.getMethod(), lastEx,
argSaver);
CleanUpStrategy strategy = definition.getCleanUpStrategy();
if (strategy.giveUpTotaly(context)) {
doLog("strategy says we should give up", exceptions);
throw lastEx;
}
strategy.cleanUp(context);
Object[] loadedArgs = argSaver.restoreArgs();
try {
return invocation.proceed(loadedArgs);
} catch (Throwable ex) {
exceptions.add(ex);
// we are in recursion, so do a bit clean up