< Summary

Class:Azure.Storage.StorageResponseClassifier
Assembly:Azure.Storage.Queues
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Common\src\Shared\StorageResponseClassifier.cs
Covered lines:8
Uncovered lines:1
Coverable lines:9
Total lines:47
Line coverage:88.8% (8 of 9)
Covered branches:13
Total branches:16
Branch coverage:81.2% (13 of 16)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_SecondaryStorageUri()-100%100%
IsRetriableResponse(...)-87.5%81.25%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Common\src\Shared\StorageResponseClassifier.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using Azure.Core;
 6
 7namespace Azure.Storage
 8{
 9    internal class StorageResponseClassifier : ResponseClassifier
 10    {
 11        /// <summary>
 12        /// The secondary URI to be used for retries on failed read requests
 13        /// </summary>
 19014        public Uri SecondaryStorageUri { get; set; }
 15
 16        /// <summary>
 17        /// Overridden version of IsRetriableResponse that allows for Storage specific retry logic.
 18        /// </summary>
 19        /// <param name="message">The message containing both Response and Request</param>
 20        /// <returns></returns>
 21        public override bool IsRetriableResponse(HttpMessage message)
 22        {
 23            // If secondary storage Uri was specified, we want to retry if the current attempt was against the secondary
 24            // get a response of NotFound. This is because the resource may not have been propagated to secondary Uri ye
 12625            if (SecondaryStorageUri != null &&
 12626                message.Request.Uri.Host == SecondaryStorageUri.Host &&
 12627                message.Response.Status == Constants.HttpStatusCode.NotFound)
 28            {
 829                return true;
 30            }
 31
 32            // Retry select Storage service error codes
 11833            if (message.Response.Status >= 400 &&
 11834                message.Response.Headers.TryGetValue(Constants.HeaderNames.ErrorCode, out var error))
 35            {
 36                switch (error)
 37                {
 38                    case Constants.ErrorCodes.InternalError:
 39                    case Constants.ErrorCodes.OperationTimedOut:
 40                    case Constants.ErrorCodes.ServerBusy:
 041                        return true;
 42                }
 43            }
 11844            return base.IsRetriableResponse(message);
 45        }
 46    }
 47}