I'm having a weird problem with @Retryable annotation.
It suppose to be fired only with the defined exception classes on value property:
@Retryable(value = {IllegalArgumentException.class}, maxAttempts = 2, backoff = @Backoff(delay = 50))
But, it's being fired with any exception:
org.springframework.retry.ExhaustedRetryException: Cannot locate recovery method; nested exception is org.springframework.web.client.HttpClientErrorException$Forbidden: 403 : "{"timestamp":"2021-11-13T16:46:32.842+00:00", ---SO ON---
All documents I see, says, only work with exceptions indicated on value property.
Any ideas?
Kind regards
EDITED:
By ask of @Hans-Christian this are the code:
@Retryable(value = {IllegalArgumentException.class}, maxAttempts = 2, backoff = @Backoff(delay = 50))
public ResponseEntity<Object> subscriptionGet(UUID subscriptionId){
ResponseEntity response = restTemplate.getForEntity(USER_SUBSCRIPTION_GET_ID_URL, SubscriptionResponse.class, subscriptionId);
return response;
}
@Recover
public ResponseEntity<Object> recoverSubscriptionGet(IllegalArgumentException e, UUID subscriptionId){
log.error("Unable to reach service: {}", e.getMessage());
return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE);
}
In case of other kind of Exception, like HttpClientErrorException.Forbidden
the retry fires and lost great deal of time, trying to find this Recover