Skip to content

ResponseErrorHandler used in RetryUtils fails with Spring Framework 7.x #3415

@sobychacko

Description

@sobychacko

Problem

Our code breaks when users upgrade to Spring 7 because we override the deprecated handleError(ClientHttpResponse) method that gets completely removed.

Current code:

@Override public void handleError(@NonNull ClientHttpResponse response) throws IOException { // our error handling logic }

What changed:

  • Spring 6.2.x: Has both handleError(response) and handleError(url, method, response)
  • Spring 7.x: Removes the deprecated handleError(response) method entirely

Solution

Implement both methods, but don't use @Override on the old one:

@Override public void handleError(URI url, HttpMethod method, @NonNull ClientHttpResponse response) throws IOException { handleError(response); // delegate to existing logic } // No @Override annotation - works in both versions public void handleError(@NonNull ClientHttpResponse response) throws IOException { // existing error handling logic stays here }

How it works:

  • When using Spring 6.2.x, we call the old method directly (no overhead)
  • When using Spring 7.x, we call the new method, which delegates to our logic
  • Same behavior, works with both versions

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions