Skip to content

Commit f2a0497

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 374c09e commit f2a0497

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;
@@ -50,6 +52,7 @@
5052
* @author Christian Tzolov
5153
* @author SriVarshan P
5254
* @author Seunggyu Lee
55+
* @author Issam El-atif
5356
*/
5457
@AutoConfiguration
5558
@ConditionalOnClass(RetryUtils.class)
@@ -104,13 +107,19 @@ public boolean hasError(@NonNull ClientHttpResponse response) throws IOException
104107
}
105108

106109
@Override
110+
public void handleError(URI url, HttpMethod method, @NonNull ClientHttpResponse response)
111+
throws IOException {
112+
handleError(response);
113+
}
114+
115+
@SuppressWarnings("removal")
107116
public void handleError(@NonNull ClientHttpResponse response) throws IOException {
108117
if (!response.getStatusCode().isError()) {
109118
return;
110119
}
111120

112121
String error = StreamUtils.copyToString(response.getBody(), StandardCharsets.UTF_8);
113-
if (error == null || error.isEmpty()) {
122+
if (error.isEmpty()) {
114123
error = "No response body available";
115124
}
116125

0 commit comments

Comments
 (0)