1111#include < aws/core/utils/Outcome.h>
1212#include < aws/core/utils/StringUtils.h>
1313#include < aws/core/utils/local/Random.h>
14+ #include < aws/core/utils/logging/LogMacros.h>
1415
1516using namespace Aws ::Utils::Threading;
1617
18+ static const char RETRY_STRATEGY_TAG [] = " StandardRetryStrategy" ;
19+
1720namespace Aws
1821{
1922 namespace Client
@@ -22,6 +25,11 @@ namespace Aws
2225 static const int RETRY_COST = 5 ;
2326 static const int TIMEOUT_RETRY_COST = 10 ;
2427
28+ static bool IsNewRetriesEnabled ()
29+ {
30+ return Aws::Utils::StringUtils::ToLower (Aws::Environment::GetEnv (" AWS_NEW_RETRIES_2026" ).c_str ()) == " true" ;
31+ }
32+
2533 struct StandardRetryStrategy ::RetryImpl
2634 {
2735 virtual ~RetryImpl () = default ;
@@ -54,7 +62,12 @@ namespace Aws
5462 auto it = headers.find (" x-amz-retry-after" );
5563 if (it != headers.end ())
5664 {
57- double headerSec = static_cast <double >(Aws::Utils::StringUtils::ConvertToInt64 (it->second .c_str ())) / 1000.0 ;
65+ long long headerMs = Aws::Utils::StringUtils::ConvertToInt64 (it->second .c_str ());
66+ if (headerMs < 0 )
67+ {
68+ AWS_LOGSTREAM_DEBUG (RETRY_STRATEGY_TAG , " Ignoring invalid x-amz-retry-after value: " << it->second );
69+ }
70+ double headerSec = static_cast <double >(headerMs) / 1000.0 ;
5871 double clamped = (std::max)(t_i, (std::min)(headerSec, 5.0 + t_i));
5972 return static_cast <long >(clamped * 1000.0 );
6073 }
@@ -66,7 +79,7 @@ namespace Aws
6679
6780 static Aws::UniquePtr<StandardRetryStrategy::RetryImpl> CreateRetryImpl ()
6881 {
69- if (Aws::Environment::GetEnv ( " AWS_NEW_RETRIES_2026 " ) == " true " )
82+ if (IsNewRetriesEnabled () )
7083 {
7184 return Aws::MakeUnique<NewRetriesImpl>(" StandardRetryStrategy" );
7285 }
@@ -75,7 +88,7 @@ namespace Aws
7588
7689 static std::shared_ptr<RetryQuotaContainer> CreateQuotaContainer ()
7790 {
78- if (Aws::Environment::GetEnv ( " AWS_NEW_RETRIES_2026 " ) == " true " )
91+ if (IsNewRetriesEnabled () )
7992 {
8093 return Aws::MakeShared<ThrottleBasedRetryQuotaContainer>(" StandardRetryStrategy" );
8194 }
0 commit comments