@@ -15,7 +15,6 @@ import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProvider
1515import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProviderChain
1616import aws.smithy.kotlin.runtime.collections.Attributes
1717import aws.smithy.kotlin.runtime.content.asByteStream
18- import aws.smithy.kotlin.runtime.http.engine.HttpClientEngine
1918import aws.smithy.kotlin.runtime.http.engine.crt.CrtHttpEngine
2019import aws.smithy.kotlin.runtime.time.toJvmInstant
2120import io.cloudshiftdev.gradle.codeartifact.CodeArtifactEndpoint
@@ -40,8 +39,7 @@ internal interface CodeArtifactService {
4039
4140internal class DefaultCodeArtifactService : CodeArtifactService {
4241 private val logger = Logging .getLogger(DefaultCodeArtifactService ::class .java)
43- private val httpClient by lazy { CrtHttpEngine () }
44- private val clientFactory = CodeArtifactClientFactory ({ httpClient })
42+ private val clientFactory = CodeArtifactClientFactory ()
4543
4644 override fun getAuthorizationToken (endpoint : CodeArtifactEndpoint ): CodeArtifactToken {
4745 val codeArtifact = clientFactory.create(endpoint)
@@ -113,24 +111,27 @@ internal class DefaultCodeArtifactService : CodeArtifactService {
113111 }
114112}
115113
116- private class CodeArtifactClientFactory (private val httpClientFactory : () -> HttpClientEngine ) {
114+ private class CodeArtifactClientFactory () {
117115 private val logger = Logging .getLogger(CodeArtifactClientFactory ::class .java)
118116 private val systemVarResolver = DefaultSystemVarResolver ()
119117
120118 private val clientCache = ConcurrentHashMap <String , CodeartifactClient >()
121119
122120 fun create (endpoint : CodeArtifactEndpoint ): CodeartifactClient {
123121 return clientCache.computeIfAbsent(endpoint.cacheKey) {
122+ val httpEnginex = CrtHttpEngine ()
124123 CodeartifactClient {
125124 region = endpoint.region
126- credentialsProvider = buildCredentialsProvider(endpoint.url.queryParameters())
127- this .httpClient = this @CodeArtifactClientFactory.httpClientFactory()
125+ credentialsProvider =
126+ buildCredentialsProvider(endpoint.url.queryParameters(), httpEnginex)
127+ this .httpClient = httpEnginex
128128 }
129129 }
130130 }
131131
132132 private fun buildCredentialsProvider (
133- queryParameters : Map <String , String >
133+ queryParameters : Map <String , String >,
134+ httpEnginex : CrtHttpEngine ,
134135 ): CredentialsProvider {
135136 fun mask (value : String? ): String? =
136137 when {
@@ -181,7 +182,7 @@ private class CodeArtifactClientFactory(private val httpClientFactory: () -> Htt
181182 assumeRoleArn?.let { roleArn ->
182183 StsAssumeRoleCredentialsProvider (
183184 bootstrapCredentialsProvider = bootstrapProviders,
184- httpClient = this @CodeArtifactClientFactory.httpClientFactory() ,
185+ httpClient = httpEnginex ,
185186 assumeRoleParameters =
186187 AssumeRoleParameters (
187188 roleArn = roleArn,
0 commit comments