Skip to content

Commit 044c2ba

Browse files
committed
Replaced all instances of HttpStatusCode.TooManyRequests with (HttpStatusCode)429 to ensure compatibility across all target frameworks
1 parent f0a75e8 commit 044c2ba

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

csharp/src/Drivers/Databricks/RetryHttpHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ protected override async Task<HttpResponseMessage> SendAsync(
136136
request.Content = null;
137137

138138
// Check if we would exceed the timeout after waiting, based on error type
139-
bool isTooManyRequests = response.StatusCode == HttpStatusCode.TooManyRequests;
139+
bool isTooManyRequests = response.StatusCode == (HttpStatusCode)429;
140140
if (isTooManyRequests)
141141
{
142142
// Check 429 rate limit timeout
@@ -181,7 +181,7 @@ protected override async Task<HttpResponseMessage> SendAsync(
181181
private bool IsRetryableStatusCode(HttpStatusCode statusCode)
182182
{
183183
// Check too many requests separately
184-
if (statusCode == HttpStatusCode.TooManyRequests) // 429
184+
if (statusCode == (HttpStatusCode)429) // 429 Too Many Requests
185185
return _rateLimitRetryEnabled;
186186

187187
// Check other retryable codes

csharp/test/Drivers/Databricks/Unit/RetryHttpHandlerTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ public async Task RetryHandlerHandlesRateLimitWithSeparateTimeout()
321321
{
322322
// Create a mock handler that returns a TooManyRequests (429) response with a Retry-After header
323323
var mockHandler = new MockHttpMessageHandler(
324-
new HttpResponseMessage(HttpStatusCode.TooManyRequests)
324+
new HttpResponseMessage((HttpStatusCode)429)
325325
{
326326
Headers = { { "Retry-After", "1" } },
327327
Content = new StringContent("Too Many Requests")
@@ -356,7 +356,7 @@ public async Task RetryHandlerRespectsRateLimitTimeout()
356356
{
357357
// Create a mock handler that always returns a TooManyRequests (429) response with a Retry-After header
358358
var mockHandler = new MockHttpMessageHandler(
359-
new HttpResponseMessage(HttpStatusCode.TooManyRequests)
359+
new HttpResponseMessage((HttpStatusCode)429)
360360
{
361361
Headers = { { "Retry-After", "2" } },
362362
Content = new StringContent("Too Many Requests")

0 commit comments

Comments
 (0)