Skip to content

Commit 9df6272

Browse files
gmediciartembilan
authored andcommitted
Some various simple fixes
* Fix `SimpleRetryPolicy` for NPE when `context.getLastThrowable()` is `null` Set `NO_RECOVERY` if it cannot retry and that exception is null * Fix `RecoverAnnotationRecoveryHandlerTests` for a proper return value in the composite `recoverByComposedRetryableAnnotationName` annotation test
1 parent 2d54999 commit 9df6272

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/main/java/org/springframework/retry/policy/SimpleRetryPolicy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public int getMaxAttempts() {
210210
public boolean canRetry(RetryContext context) {
211211
Throwable t = context.getLastThrowable();
212212
boolean can = (t == null || retryForException(t)) && context.getRetryCount() < getMaxAttempts();
213-
if (!can && !this.recoverableClassifier.classify(t)) {
213+
if (!can && t != null && !this.recoverableClassifier.classify(t)) {
214214
context.setAttribute(RetryContext.NO_RECOVERY, true);
215215
}
216216
else {

src/test/java/org/springframework/retry/annotation/RecoverAnnotationRecoveryHandlerTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
* @author Randell Callahan
4444
* @author Nathanaël Roberts
4545
* @author Maksim Kita
46-
* @Author Gianluca Medici
46+
* @author Gianluca Medici
4747
*/
4848
public class RecoverAnnotationRecoveryHandlerTests {
4949

@@ -661,7 +661,7 @@ public int fooRecover(Throwable throwable, String name) {
661661
}
662662

663663
public int barRecover(Throwable throwable, String name) {
664-
return 2;
664+
return 4;
665665
}
666666

667667
}

0 commit comments

Comments
 (0)