Skip to content

Commit c7f7b68

Browse files
authored
GH-4082: Fix ResourceAccessException retry for network connectivity errors(#4094)
Fixes #4082 Auto-cherry-pick to 1.0.x Signed-off-by: Mattia Pasetto <[email protected]>
1 parent 1ad9235 commit c7f7b68

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.springframework.retry.RetryListener;
3333
import org.springframework.retry.support.RetryTemplate;
3434
import org.springframework.util.StreamUtils;
35+
import org.springframework.web.client.ResourceAccessException;
3536
import org.springframework.web.client.ResponseErrorHandler;
3637

3738
/**
@@ -80,6 +81,7 @@ public void handleError(@NonNull ClientHttpResponse response) throws IOException
8081
public static final RetryTemplate DEFAULT_RETRY_TEMPLATE = RetryTemplate.builder()
8182
.maxAttempts(10)
8283
.retryOn(TransientAiException.class)
84+
.retryOn(ResourceAccessException.class)
8385
.exponentialBackoff(Duration.ofMillis(2000), 5, Duration.ofMillis(3 * 60000))
8486
.withListener(new RetryListener() {
8587

@@ -98,6 +100,7 @@ public <T extends Object, E extends Throwable> void onError(RetryContext context
98100
public static final RetryTemplate SHORT_RETRY_TEMPLATE = RetryTemplate.builder()
99101
.maxAttempts(10)
100102
.retryOn(TransientAiException.class)
103+
.retryOn(ResourceAccessException.class)
101104
.fixedBackoff(Duration.ofMillis(100))
102105
.withListener(new RetryListener() {
103106

0 commit comments

Comments
 (0)