diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/StatefulRetryStepFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/StatefulRetryStepFactoryBean.java index b6d7d307d..38d470ba0 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/StatefulRetryStepFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/StatefulRetryStepFactoryBean.java @@ -215,9 +215,9 @@ public class StatefulRetryStepFactoryBean extends SkipLimitStepFactoryBean { } }, itemKeyGenerator != null ? itemKeyGenerator.getKey(item) : item); retryCallback.setRecoveryCallback(new RecoveryCallback() { - public Object recover(Throwable throwable) { + public Object recover(RetryContext context) { if (itemRecoverer != null) { - return itemRecoverer.recover(item, throwable); + return itemRecoverer.recover(item, context.getLastThrowable()); } return null; } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/RecoveryCallback.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/RecoveryCallback.java index 8d03988e3..f35519e10 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/RecoveryCallback.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/RecoveryCallback.java @@ -25,10 +25,10 @@ package org.springframework.batch.retry; public interface RecoveryCallback { /** - * @param throwable the cause of the failure that we are to recover from + * @param context the current retry context * @return an Object that can be used to replace the callback result that * failed */ - Object recover(Throwable throwable); + Object recover(RetryContext context); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/interceptor/StatefulRetryOperationsInterceptor.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/interceptor/StatefulRetryOperationsInterceptor.java index c8f4946af..ce164704d 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/interceptor/StatefulRetryOperationsInterceptor.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/interceptor/StatefulRetryOperationsInterceptor.java @@ -119,9 +119,9 @@ public class StatefulRetryOperationsInterceptor implements MethodInterceptor { } }, keyGenerator != null ? keyGenerator.getKey(item) : item); callback.setRecoveryCallback(new RecoveryCallback() { - public Object recover(Throwable cause) { + public Object recover(RetryContext context) { if (recoverer != null) { - return recoverer.recover(item, cause); + return recoverer.recover(item, context.getLastThrowable()); } return item; } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/policy/RecoveryCallbackRetryPolicy.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/policy/RecoveryCallbackRetryPolicy.java index 345f60d03..7dc8fdeb1 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/policy/RecoveryCallbackRetryPolicy.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/policy/RecoveryCallbackRetryPolicy.java @@ -195,11 +195,6 @@ public class RecoveryCallbackRetryPolicy extends AbstractStatefulRetryPolicy { delegate.registerThrowable(this.delegateContext, throwable); } - public boolean isExternal() { - // Not called... - throw new UnsupportedOperationException("Not supported - this code should be unreachable."); - } - public boolean shouldRethrow(RetryContext context) { // Not called... throw new UnsupportedOperationException("Not supported - this code should be unreachable."); @@ -210,9 +205,9 @@ public class RecoveryCallbackRetryPolicy extends AbstractStatefulRetryPolicy { retryContextCache.remove(key); RepeatSynchronizationManager.setCompleteOnly(); if (recoverer != null) { - return recoverer.recover(context.getLastThrowable()); + return recoverer.recover(context); } - logger.info("No recover callback provided. Returning null from recovery step."); + logger.info("No recovery callback provided. Returning null from recovery step."); // Don't want to call the delegate here - it would throw an exception return null; } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/retry/policy/RecoveryRetryPolicyTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/retry/policy/RecoveryRetryPolicyTests.java index 58585158c..fec5edea6 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/retry/policy/RecoveryRetryPolicyTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/retry/policy/RecoveryRetryPolicyTests.java @@ -150,7 +150,7 @@ public class RecoveryRetryPolicyTests extends TestCase { } }); callback.setRecoveryCallback(new RecoveryCallback() { - public Object recover(Throwable cause) { + public Object recover(RetryContext context) { count++; list.add(input); return input; @@ -189,7 +189,7 @@ public class RecoveryRetryPolicyTests extends TestCase { } }); callback.setRecoveryCallback(new RecoveryCallback() { - public Object recover(Throwable cause) { + public Object recover(RetryContext context) { count++; list.add(input); return input; diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/container/jms/BatchMessageListenerContainerIntegrationTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/container/jms/BatchMessageListenerContainerIntegrationTests.java index 5fc5dd32a..3d645bf53 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/container/jms/BatchMessageListenerContainerIntegrationTests.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/container/jms/BatchMessageListenerContainerIntegrationTests.java @@ -147,7 +147,7 @@ public class BatchMessageListenerContainerIntegrationTests extends AbstractDepen } }, msg.getJMSMessageID()); callback.setRecoveryCallback(new RecoveryCallback() { - public Object recover(Throwable throwable) { + public Object recover(RetryContext context) { recovered++; logger.debug("Recovered: " + msg); return msg; diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/jms/ExternalRetryInBatchTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/jms/ExternalRetryInBatchTests.java index 2345335a0..1463c00e1 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/jms/ExternalRetryInBatchTests.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/jms/ExternalRetryInBatchTests.java @@ -149,8 +149,8 @@ public class ExternalRetryInBatchTests extends AbstractDependencyInjectionSpring }); callback.setRecoveryCallback(new RecoveryCallback() { - public Object recover(Throwable throwable) { - return provider.recover(item, throwable); + public Object recover(RetryContext context) { + return provider.recover(item, context.getLastThrowable()); } }); diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/retry/jms/ExternalRetryTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/retry/jms/ExternalRetryTests.java index 78f1c780e..d6eb46d8b 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/retry/jms/ExternalRetryTests.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/retry/jms/ExternalRetryTests.java @@ -199,8 +199,8 @@ public class ExternalRetryTests extends AbstractDependencyInjectionSpringContext }); callback.setRecoveryCallback(new RecoveryCallback() { - public Object recover(Throwable throwable) { - return provider.recover(item, throwable); + public Object recover(RetryContext context) { + return provider.recover(item, context.getLastThrowable()); } });