Skip to content

Commit 23b750b

Browse files
committed
Add Spring Framework 7.x compatibility to SpringAiRetryAutoConfiguration#responseErrorHandler
Related to #4720 Signed-off-by: Issam El-atif <issam.elatif@gmail.com>
1 parent b452e89 commit 23b750b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

auto-configurations/common/spring-ai-autoconfigure-retry/src/main/java/org/springframework/ai/retry/autoconfigure/SpringAiRetryAutoConfiguration.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.ai.retry.autoconfigure;
1818

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

2223
import org.slf4j.Logger;
@@ -30,6 +31,7 @@
3031
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
3132
import org.springframework.boot.context.properties.EnableConfigurationProperties;
3233
import org.springframework.context.annotation.Bean;
34+
import org.springframework.http.HttpMethod;
3335
import org.springframework.http.client.ClientHttpResponse;
3436
import org.springframework.lang.NonNull;
3537
import org.springframework.retry.RetryCallback;
@@ -47,6 +49,7 @@
4749
*
4850
* @author Christian Tzolov
4951
* @author SriVarshan P
52+
* @author Issam El-atif
5053
*/
5154
@AutoConfiguration
5255
@ConditionalOnClass(RetryUtils.class)
@@ -87,13 +90,19 @@ public boolean hasError(@NonNull ClientHttpResponse response) throws IOException
8790
}
8891

8992
@Override
93+
public void handleError(URI url, HttpMethod method, @NonNull ClientHttpResponse response)
94+
throws IOException {
95+
handleError(response);
96+
}
97+
98+
@SuppressWarnings("removal")
9099
public void handleError(@NonNull ClientHttpResponse response) throws IOException {
91100
if (!response.getStatusCode().isError()) {
92101
return;
93102
}
94103

95104
String error = StreamUtils.copyToString(response.getBody(), StandardCharsets.UTF_8);
96-
if (error == null || error.isEmpty()) {
105+
if (error.isEmpty()) {
97106
error = "No response body available";
98107
}
99108

0 commit comments

Comments
 (0)