Skip to content

Commit 5ecfcce

Browse files
sobychackoilayaperumalg
authored andcommitted
GH-3415: Add Spring Framework 7.x compatibility to RetryUtils#ResponseErrorHandler
Fixes: #3415 - Remove @OverRide annotation from handleError(ClientHttpResponse) method to support compilation against both Spring 6.2.x and 7.x - Add delegation from new handleError(URI, HttpMethod, ClientHttpResponse) method to maintain backward compatibility - Preserve existing error handling logic This change allows Spring AI to work seamlessly across Spring Framework versions 6.x and 7.x without requiring reflection or version detection at runtime. Signed-off-by: Soby Chacko <[email protected]>
1 parent 9aa0c9a commit 5ecfcce

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

spring-ai-retry/src/main/java/org/springframework/ai/retry/RetryUtils.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 the original author or authors.
2+
* Copyright 2023-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,12 +17,14 @@
1717
package org.springframework.ai.retry;
1818

1919
import java.io.IOException;
20+
import java.net.URI;
2021
import java.nio.charset.StandardCharsets;
2122
import java.time.Duration;
2223

2324
import org.slf4j.Logger;
2425
import org.slf4j.LoggerFactory;
2526

27+
import org.springframework.http.HttpMethod;
2628
import org.springframework.http.client.ClientHttpResponse;
2729
import org.springframework.lang.NonNull;
2830
import org.springframework.retry.RetryCallback;
@@ -37,6 +39,7 @@
3739
* provides a default RetryTemplate and a default ResponseErrorHandler.
3840
*
3941
* @author Christian Tzolov
42+
* @author Soby Chacko
4043
* @since 0.8.1
4144
*/
4245
public abstract class RetryUtils {
@@ -49,6 +52,11 @@ public boolean hasError(@NonNull ClientHttpResponse response) throws IOException
4952
}
5053

5154
@Override
55+
public void handleError(URI url, HttpMethod method, @NonNull ClientHttpResponse response) throws IOException {
56+
handleError(response);
57+
}
58+
59+
@SuppressWarnings("removal")
5260
public void handleError(@NonNull ClientHttpResponse response) throws IOException {
5361
if (response.getStatusCode().isError()) {
5462
String error = StreamUtils.copyToString(response.getBody(), StandardCharsets.UTF_8);

0 commit comments

Comments
 (0)