Simplify HttpRequestException handling in retry logic.

Replaced specific transient status code check for HttpRequestException with a more generalized handling approach. This ensures all HTTP exceptions are retried, improving robustness and simplifying the logic.
This commit is contained in:
Sipke Schoorstra 2025-03-03 16:47:06 +01:00
parent 966ee3c160
commit f71fbd23c7
No known key found for this signature in database
GPG key ID: 5C10502B28A4268F

View file

@ -264,7 +264,7 @@ public abstract class SendHttpRequestBase : Activity<HttpResponseMessage>
{
ShouldHandle = new PredicateBuilder<HttpResponseMessage>()
.Handle<TimeoutException>() // Specific timeout exception
.Handle<HttpRequestException>(ex => IsTransientStatusCode(ex.StatusCode)) // Network errors or transient HTTP codes
.Handle<HttpRequestException>() // Any HTTP exception
.HandleResult(response => IsTransientStatusCode(response.StatusCode)),
MaxRetryAttempts = 4,
UseJitter = false, // If enabled, adds a random value between -25% and +25% of the calculated Delay, except if BackoffType is Exponential, where a DecorrelatedJitterBackoffV2 formula is used for jitter calculation. That formula is based on Polly.Contrib.WaitAndRetry.