Skip to content

Migrate Spring Retry to Spring Resilience - #1057

Open
arnabnandy7 wants to merge 2 commits into
openrewrite:mainfrom
arnabnandy7:refactor/retry-to-resilience4j
Open

Migrate Spring Retry to Spring Resilience#1057
arnabnandy7 wants to merge 2 commits into
openrewrite:mainfrom
arnabnandy7:refactor/retry-to-resilience4j

Conversation

@arnabnandy7

@arnabnandy7 arnabnandy7 commented Jul 3, 2026

Copy link
Copy Markdown

What's changed?

  • Added the org.openrewrite.java.spring.framework.MigrateSpringRetryToResilience recipe to spring-framework-70.yml.
  • Automatically removes the external org.springframework.retry:spring-retry dependency.
  • Migrates type imports and usages for RetryTemplate, RetryCallback, RetryListener, @EnableRetry, and @Retryable to their new built-in equivalents in org.springframework.core.retry.* and org.springframework.resilience.annotation.*.
  • Added a custom Java recipe CleanUpRetryableTypeArguments to adjust parameterized type arguments, converting the 2-parameter signature Retryable<R, E> (migrated from RetryCallback) to the new 1-parameter Retryable<R> signature.
  • Added comprehensive unit tests under MigrateSpringRetryToResilienceTest.java.

What's your motivation?

Anything in particular you'd like reviewers to focus on?

  • The custom CleanUpRetryableTypeArguments visitor which correctly handles clearing out the secondary type parameter (E) of migrated generic references.

Have you considered any alternatives or workarounds?

  • Attempted to do this entirely declaratively in YAML; however, built-in recipes like ChangeType do not automatically drop type arguments when changing to a class with a different type parameter count. A custom Java visitor was necessary to clean this up safely.
  • Scoped out complex builder-chain modifications (e.g. RetryTemplate.builder()) and @Recover method refactoring to keep this upgrade path safe and mechanical.

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Jul 3, 2026
@timtebeek
timtebeek self-requested a review July 4, 2026 11:26
Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Spring Boot 4 - Migrate RetryTemplate from Spring Retry to Spring Resilience

1 participant