@@ -617,33 +617,47 @@ std::shared_ptr<RetryStrategy> InitRetryStrategy(int maxAttempts, Aws::String re
617617 }
618618 else
619619 {
620- if (Aws::Utils::StringUtils::ToLower (Aws::Environment::GetEnv (" AWS_NEW_RETRIES_2026" ).c_str ()) != " true" )
621- {
622- if (maxAttempts < 0 )
623- {
624- retryStrategy = Aws::MakeShared<StandardRetryStrategy>(CLIENT_CONFIG_TAG );
625- }
626- else
627- {
628- retryStrategy = Aws::MakeShared<StandardRetryStrategy>(CLIENT_CONFIG_TAG , maxAttempts);
629- }
630- }
631- else
632- {
633- retryStrategy = Aws::MakeShared<DefaultRetryStrategy>(CLIENT_CONFIG_TAG );
634- }
620+ retryStrategy = Aws::MakeShared<DefaultRetryStrategy>(CLIENT_CONFIG_TAG );
635621 }
636622
637623 return retryStrategy;
638624}
639625
626+ static int ResolveConfiguredMaxAttempts ()
627+ {
628+ Aws::String maxAttemptsString = Aws::Environment::GetEnv (" AWS_MAX_ATTEMPTS" );
629+ if (maxAttemptsString.empty ())
630+ {
631+ maxAttemptsString = Aws::Config::GetCachedConfigValue (" max_attempts" );
632+ }
633+ // In case users specify 0 explicitly to disable retry.
634+ if (maxAttemptsString == " 0" )
635+ {
636+ return 0 ;
637+ }
638+ int maxAttempts = static_cast <int >(Aws::Utils::StringUtils::ConvertToInt32 (maxAttemptsString.c_str ()));
639+ if (maxAttempts == 0 )
640+ {
641+ AWS_LOGSTREAM_INFO (CLIENT_CONFIG_TAG , " Retry Strategy will use the default max attempts." );
642+ return -1 ;
643+ }
644+ return maxAttempts;
645+ }
646+
640647std::shared_ptr<RetryStrategy> InitRetryStrategy (int maxAttempts, Aws::String retryMode, double transientBackoffBaseSec) {
641648 if (Aws::Utils::StringUtils::ToLower (Aws::Environment::GetEnv (" AWS_NEW_RETRIES_2026" ).c_str ()) != " true" )
642649 {
643650 // Gate is off: ignore service-specific tuning, use default behavior
644651 return InitRetryStrategy (retryMode);
645652 }
646653
654+ // maxAttempts is a service default. A max attempts value the customer configured wins.
655+ const int configuredMaxAttempts = ResolveConfiguredMaxAttempts ();
656+ if (configuredMaxAttempts >= 0 )
657+ {
658+ maxAttempts = configuredMaxAttempts;
659+ }
660+
647661 // Only standard mode honors a service-specific backoff base; other modes are unaffected,
648662 // so they go through the default-base path.
649663 if (ResolveRetryMode (retryMode) != " standard" )
@@ -657,28 +671,7 @@ std::shared_ptr<RetryStrategy> InitRetryStrategy(int maxAttempts, Aws::String re
657671
658672std::shared_ptr<RetryStrategy> InitRetryStrategy (Aws::String retryMode)
659673{
660- int maxAttempts = 0 ;
661- Aws::String maxAttemptsString = Aws::Environment::GetEnv (" AWS_MAX_ATTEMPTS" );
662- if (maxAttemptsString.empty ())
663- {
664- maxAttemptsString = Aws::Config::GetCachedConfigValue (" max_attempts" );
665- }
666- // In case users specify 0 explicitly to disable retry.
667- if (maxAttemptsString == " 0" )
668- {
669- maxAttempts = 0 ;
670- }
671- else
672- {
673- maxAttempts = static_cast <int >(Aws::Utils::StringUtils::ConvertToInt32 (maxAttemptsString.c_str ()));
674- if (maxAttempts == 0 )
675- {
676- AWS_LOGSTREAM_INFO (CLIENT_CONFIG_TAG , " Retry Strategy will use the default max attempts." );
677- maxAttempts = -1 ;
678- }
679- }
680-
681- return InitRetryStrategy (maxAttempts, retryMode);
674+ return InitRetryStrategy (ResolveConfiguredMaxAttempts (), retryMode);
682675}
683676
684677Aws::String ClientConfiguration::LoadConfigFromEnvOrProfile (const Aws::String& envKey,
0 commit comments