Skip to content
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

Allow composing @Retryable annotation with @AliasFor recover method #313

Merged
merged 3 commits into from
Oct 5, 2022

Conversation

gmedici
Copy link
Contributor

@gmedici gmedici commented Oct 3, 2022

Creating a custom annotation composing @Retryable will not get the actual recover argument value even when the recover method is annotated with @AliasFor. Eg:

@Target({ ElementType.METHOD, ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Retryable(maxAttempts = 4)
public @interface ComposedRetryable {
    @AliasFor(annotation = Retryable.class, attribute = "recover")
    String recover() default "";
}

The reason is that RecoverAnnotationRecoveryHandler is still using AnnotationUtils.findAnnotation() instead of AnnotatedElementUtils.findMergedAnnotation()

…rgument annotated with @AliasFor by using `AnnotatedElementUtils.findMergedAnnotation` in `AnnotationAwareRetryOperationsInterceptor`

fix(Retryable): allow composing `Retryable` annotation with 'recover' argument annotated with @AliasFor by using `AnnotatedElementUtils.findMergedAnnotation` in `RecoverAnnotationRecoveryHandler`
@gmedici gmedici changed the title Allow composing Retryable annotation with @AliasFor recover method Allow composing @Retryable annotation with @AliasFor recover method Oct 3, 2022
Copy link
Member

@artembilan artembilan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also would be great if you add some explanation and sample for this feature in the README of the project: https://github.com/spring-projects/spring-retry#declarative-retry.

Thank you!

…composition with @retryable

Added author and fix import style.
README.md Outdated Show resolved Hide resolved
@artembilan artembilan merged commit 9ffdd55 into spring-projects:main Oct 5, 2022
@artembilan
Copy link
Member

... and back-ported to 1.3.x as 2e7a73c after some minor conflict resolution.

@gmedici ,

thank you very much for contribution; looking forward for more!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants