diff --git a/src/main/java/org/springframework/retry/policy/SimpleRetryPolicy.java b/src/main/java/org/springframework/retry/policy/SimpleRetryPolicy.java index 162c154..fa57162 100644 --- a/src/main/java/org/springframework/retry/policy/SimpleRetryPolicy.java +++ b/src/main/java/org/springframework/retry/policy/SimpleRetryPolicy.java @@ -210,7 +210,7 @@ public class SimpleRetryPolicy implements RetryPolicy { public boolean canRetry(RetryContext context) { Throwable t = context.getLastThrowable(); boolean can = (t == null || retryForException(t)) && context.getRetryCount() < getMaxAttempts(); - if (!can && !this.recoverableClassifier.classify(t)) { + if (!can && t != null && !this.recoverableClassifier.classify(t)) { context.setAttribute(RetryContext.NO_RECOVERY, true); } else { diff --git a/src/test/java/org/springframework/retry/annotation/RecoverAnnotationRecoveryHandlerTests.java b/src/test/java/org/springframework/retry/annotation/RecoverAnnotationRecoveryHandlerTests.java index fb87627..62d8dda 100644 --- a/src/test/java/org/springframework/retry/annotation/RecoverAnnotationRecoveryHandlerTests.java +++ b/src/test/java/org/springframework/retry/annotation/RecoverAnnotationRecoveryHandlerTests.java @@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Randell Callahan * @author Nathanaƫl Roberts * @author Maksim Kita - * @Author Gianluca Medici + * @author Gianluca Medici */ public class RecoverAnnotationRecoveryHandlerTests { @@ -661,7 +661,7 @@ public class RecoverAnnotationRecoveryHandlerTests { } public int barRecover(Throwable throwable, String name) { - return 2; + return 4; } }