private async Task RetryAsync(Exception exception, bool async, CancellationToken cancellationToken) { // Depending on the timing, the stream can be closed as a result of cancellation when the transport closes the stream. // If the user requested cancellation, we translate to TaskCanceledException, similar to what we do HttpWebRequestTransport. if (exception is ObjectDisposedException) { CancellationHelper.ThrowIfCancellationRequested(cancellationToken); } bool isNonCustomerCancelledException = exception is OperationCanceledException && !cancellationToken.IsCancellationRequested; if (!_responseClassifier.IsRetriableException(exception) && !isNonCustomerCancelledException) { ExceptionDispatchInfo.Capture(exception).Throw(); } if (_exceptions == null) { _exceptions = new List <Exception>(); } _exceptions.Add(exception); _retryCount++; if (_retryCount > _maxRetries) { throw new AggregateException($"Retry failed after {_retryCount} tries", _exceptions); } _currentStream.Dispose(); _currentStream = EnsureStream(async ? (await _asyncStreamFactory(_position).ConfigureAwait(false)) : _streamFactory(_position)); }
private async Task RetryAsync(Exception exception, bool async, CancellationToken cancellationToken) { bool isNonCustomerCancelledException = exception is OperationCanceledException && !cancellationToken.IsCancellationRequested; if (!_responseClassifier.IsRetriableException(exception) && !isNonCustomerCancelledException) { ExceptionDispatchInfo.Capture(exception).Throw(); } if (_exceptions == null) { _exceptions = new List <Exception>(); } _exceptions.Add(exception); _retryCount++; if (_retryCount > _maxRetries) { throw new AggregateException($"Retry failed after {_retryCount} tries", _exceptions); } _currentStream.Dispose(); _currentStream = EnsureStream(async ? (await _asyncStreamFactory(_position).ConfigureAwait(false)) : _streamFactory(_position)); }
private async Task RetryAsync(Exception exception, bool async) { if (!_responseClassifier.IsRetriableException(exception)) { ExceptionDispatchInfo.Capture(exception).Throw(); } if (_exceptions == null) { _exceptions = new List <Exception>(); } _exceptions.Add(exception); _retryCount++; if (_retryCount > _maxRetries) { throw new AggregateException($"Retry failed after {_retryCount} tries", _exceptions); } _currentStream = EnsureStream(async ? (await _asyncStreamFactory(_position).ConfigureAwait(false)) : _streamFactory(_position)); }
public override bool IsRetriableException(Exception exception) => _responseClassifier.IsRetriableException(exception);