-
Notifications
You must be signed in to change notification settings - Fork 519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to define recover method where the method is returning a generic List #402
Comments
See the test provided for that fix:
So, since
|
So basically I have
With spring-recover 2.0.0 that worked just fine but it fails with 2.0.4 which I've traced back to #328 This class is a helper for fetching data from numerous classes so T varies by the caller, so creating an instance for each would be a substantial code change. Hoping you have a suggestion on how I might make a recover method for that. |
You just relied on a bug or rather some side-effect which didn't honor generics.
instead of trying to trick reflection which we treat as a bug and therefore the fix you are mentioning. |
We did try with setting the recover attribute in the |
So using the recover attribute on the annotation selects the method but when trying to mach it winds up back in |
How about to make your My point is that we need to agree that |
I wound up reworking the code to use https://github.com/spring-projects/spring-retry#using-recoverycallback So in case someone else is reading this bug the solution looks like retryTemplate = RetryTemplate.builder()
.maxAttempts(maxAttempts)
.notRetryOn(List.of(NotAcceptableException.class, InstantiationException.class))
.customBackoff(BackOffPolicyBuilder.newBuilder().delay(delay).multiplier(multiplier).build())
.build();
return retryTemplate.execute(
(RetryCallback<List<T>, Exception>) context -> self.retryRunQuery(queryName, returnType, otherArgs),
context -> self.recoverQuery(context.getLastThrowable(), queryName)
); |
Thank you for feedback! Those docs are fixed now. |
We are upgrading our spring 1.3.4 properly handles a method
public List<T> myMethod()
where the recovery is defined aspublic List<T> recoverMyMethod(Throwable t)
but after #328 using version 2.0.4 it would seem that no longer works.The offending code is what was added in that bug
!methodArgType.equals(failingMethodArgType)
because the twoT
s are not equal as far as the reflection is concerned since they are on different methods; in theory they could be different but for the purpose of @Retryable/@recover they won't be.The text was updated successfully, but these errors were encountered: