From b7441f02ed81287e060dd60bbc63c4c747eb63b0 Mon Sep 17 00:00:00 2001 From: Soumava Bera Date: Tue, 7 Jan 2025 11:49:12 -0500 Subject: [PATCH] config deep copy changes --- .../include/smithy/client/AwsSmithyClient.h | 6 ++-- .../smithy/client/AwsSmithyClientBase.h | 34 ++++++++++++++++--- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClient.h b/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClient.h index 2bc4404c845..e4cfe9c2bb3 100644 --- a/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClient.h +++ b/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClient.h @@ -56,7 +56,7 @@ namespace client AwsSmithyClientT(const AwsSmithyClientT& other): AwsSmithyClientBase(Aws::MakeShared(ServiceNameT, other.m_clientConfig), other.m_serviceName, Aws::Http::CreateHttpClient(*other.m_clientConfig), Aws::MakeShared(other.m_serviceName.c_str())), - m_clientConfiguration{other.m_clientConfiguration}, + m_clientConfiguration{*static_cast(AwsSmithyClientBase::m_clientConfig.get())}, m_endpointProvider{other.m_endpointProvider}, m_authSchemeResolver{other.m_authSchemeResolver}, m_authSchemes{other.m_authSchemes}, @@ -70,7 +70,7 @@ namespace client if(this != &other) { AwsSmithyClientBase::operator=(other); - m_clientConfiguration = other.m_clientConfiguration; + m_clientConfiguration = *static_cast(AwsSmithyClientBase::m_clientConfig.get()); m_endpointProvider = other.m_endpointProvider; m_authSchemeResolver = other.m_authSchemeResolver; m_authSchemes = other.m_authSchemes; @@ -167,7 +167,7 @@ namespace client } protected: - ServiceClientConfigurationT m_clientConfiguration; + ServiceClientConfigurationT& m_clientConfiguration; std::shared_ptr m_endpointProvider{}; std::shared_ptr m_authSchemeResolver{}; Aws::UnorderedMap m_authSchemes{}; diff --git a/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClientBase.h b/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClientBase.h index 43e9f0699b8..fdf9effba07 100644 --- a/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClientBase.h +++ b/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClientBase.h @@ -69,6 +69,31 @@ namespace client { private: const char* ALLOC_TAG{"AwsSmithyClientBase"}; + + + void deepCopyClientConfiguration(const AwsSmithyClientBase& target) + { + //first create copy from target + m_clientConfig = Aws::MakeShared(target.m_serviceName.c_str(), *target.m_clientConfig); + + //then reinitialize appropriate fields unconditionally + assert(m_clientConfig->configFactories.retryStrategyCreateFn); + m_clientConfig->retryStrategy = m_clientConfig->configFactories.retryStrategyCreateFn(); + + assert(m_clientConfig->configFactories.executorCreateFn); + m_clientConfig->executor = m_clientConfig->configFactories.executorCreateFn(); + + assert(m_clientConfig->configFactories.writeRateLimiterCreateFn); + m_clientConfig->writeRateLimiter = m_clientConfig->configFactories.writeRateLimiterCreateFn(); + + assert(m_clientConfig->configFactories.readRateLimiterCreateFn); + m_clientConfig->readRateLimiter = m_clientConfig->configFactories.readRateLimiterCreateFn(); + + assert(m_clientConfig->configFactories.telemetryProviderCreateFn); + m_clientConfig->telemetryProvider = m_clientConfig->configFactories.telemetryProviderCreateFn(); + + } + public: using HttpRequest = Aws::Http::HttpRequest; using HttpResponse = Aws::Http::HttpResponse; @@ -128,22 +153,23 @@ namespace client { if (this != &target) { - m_clientConfig = target.m_clientConfig; + deepCopyClientConfiguration(target); m_serviceName = target.m_serviceName; m_userAgent = target.m_userAgent; m_httpClient = Aws::Http::CreateHttpClient(*target.m_clientConfig); m_interceptors = {Aws::MakeShared(ALLOC_TAG)}; + m_userAgent = Aws::Client::ComputeUserAgentString(m_clientConfig.get()); } return *this; } AwsSmithyClientBase(const AwsSmithyClientBase& target): - m_clientConfig{target.m_clientConfig}, m_serviceName{target.m_serviceName}, m_userAgent{target.m_userAgent}, - m_httpClient{Aws::Http::CreateHttpClient(*target.m_clientConfig)} + m_httpClient{Aws::Http::CreateHttpClient(*target.m_clientConfig)}, + m_interceptors{Aws::MakeShared(ALLOC_TAG)} { - m_interceptors = {Aws::MakeShared(ALLOC_TAG)}; + deepCopyClientConfiguration(target); } AwsSmithyClientBase(AwsSmithyClientBase&& target) = default;