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
This commit is contained in:
gmedici
2022-10-05 10:47:43 -04:00
committed by Artem Bilan
parent 2d549990f4
commit 9df6272828
2 changed files with 3 additions and 3 deletions

View File

@@ -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 {

View File

@@ -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;
}
}