Skip to content

Commit 57a26b0

Browse files
dorshaclaude
andauthored
feat(http): also retry on transient status code 520 (#337)
Add Cloudflare status code 520 ("Web Server Returned an Unknown Error") to the HTTP client's retryable status codes, alongside the existing 503/521/522/524/530. Brings this SDK in line with the go-sdk and python-sdk. Relates to descope/etc#14039 Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent a3ab40d commit 57a26b0

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/main/java/com/descope/proxy/impl/AbstractProxyImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ abstract class AbstractProxyImpl {
3636

3737
// HTTP status codes that should trigger automatic retries:
3838
// 503: Service Unavailable
39+
// 520: Web Server Returned an Unknown Error (Cloudflare)
3940
// 521: Web Server Is Down (Cloudflare)
4041
// 522: Connection Timed Out (Cloudflare)
4142
// 524: A Timeout Occurred (Cloudflare)
4243
// 530: Cloudflare error
4344
static final Set<Integer> retryableStatusCodes = Collections.unmodifiableSet(
44-
new HashSet<>(Arrays.asList(503, 521, 522, 524, 530)));
45+
new HashSet<>(Arrays.asList(503, 520, 521, 522, 524, 530)));
4546

4647
// Retry delays in milliseconds: first retry after 100ms, subsequent retries after 5000ms.
4748
// Package-private to allow overriding in tests.

src/test/java/com/descope/proxy/impl/AbstractProxyImplTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,18 @@ void testRetryDelayConfig() {
5555
@Test
5656
void testRetryStatusCodesConfig() {
5757
assertTrue(AbstractProxyImpl.retryableStatusCodes.contains(503));
58+
assertTrue(AbstractProxyImpl.retryableStatusCodes.contains(520));
5859
assertTrue(AbstractProxyImpl.retryableStatusCodes.contains(521));
5960
assertTrue(AbstractProxyImpl.retryableStatusCodes.contains(522));
6061
assertTrue(AbstractProxyImpl.retryableStatusCodes.contains(524));
6162
assertTrue(AbstractProxyImpl.retryableStatusCodes.contains(530));
62-
assertEquals(5, AbstractProxyImpl.retryableStatusCodes.size());
63+
assertEquals(6, AbstractProxyImpl.retryableStatusCodes.size());
6364
}
6465

6566
@Test
6667
@SuppressWarnings({"unchecked", "rawtypes"})
6768
void testRetryOnRetryableStatusCodes() throws IOException {
68-
List<Integer> retryableCodes = Arrays.asList(503, 521, 522, 524, 530);
69+
List<Integer> retryableCodes = Arrays.asList(503, 520, 521, 522, 524, 530);
6970
for (int statusCode : retryableCodes) {
7071
AtomicInteger callCount = new AtomicInteger(0);
7172
CloseableHttpClient mockClient = mock(CloseableHttpClient.class);

0 commit comments

Comments
 (0)