From 6896502fb09536e048be30375229b466c8ede281 Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Tue, 12 Nov 2024 21:21:39 -0600 Subject: [PATCH] Threadsafe Context --- Package.version.next | 2 +- .../Middlewares/Sha256TreeHashMiddleware.swift | 2 +- .../Sources/AWSClientRuntime/UserAgent/BusinessMetrics.swift | 4 ++-- .../customization/RulesBasedAuthSchemeResolverGenerator.kt | 2 +- .../codegen/middleware/OperationEndpointResolverMiddleware.kt | 2 +- .../smithy/aws/swift/codegen/PresignerGeneratorTests.kt | 2 +- .../RulesBasedAuthSchemeResolverGeneratorTests.kt | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Package.version.next b/Package.version.next index 99f742236db..9cc0a9d4e79 100644 --- a/Package.version.next +++ b/Package.version.next @@ -1 +1 @@ -1.0.39 \ No newline at end of file +1.0.38 \ No newline at end of file diff --git a/Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime/Middlewares/Sha256TreeHashMiddleware.swift b/Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime/Middlewares/Sha256TreeHashMiddleware.swift index 06b52ed2be9..c23906e8bbf 100644 --- a/Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime/Middlewares/Sha256TreeHashMiddleware.swift +++ b/Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime/Middlewares/Sha256TreeHashMiddleware.swift @@ -46,7 +46,7 @@ public struct Sha256TreeHashMiddleware { - get { attributes.get(key: businessMetricsKey) ?? [:] } + get { get(key: businessMetricsKey) ?? [:] } set(newPair) { var combined = businessMetrics combined.merge(newPair) { (_, new) in new } - attributes.set(key: businessMetricsKey, value: combined) + set(key: businessMetricsKey, value: combined) } } } diff --git a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/customization/RulesBasedAuthSchemeResolverGenerator.kt b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/customization/RulesBasedAuthSchemeResolverGenerator.kt index 35a2f27f64a..9980a82b0dc 100644 --- a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/customization/RulesBasedAuthSchemeResolverGenerator.kt +++ b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/customization/RulesBasedAuthSchemeResolverGenerator.kt @@ -131,7 +131,7 @@ class RulesBasedAuthSchemeResolverGenerator { } // Get endpoint param from middleware context - openBlock("guard let endpointParam = context.attributes.get(key: \$N(name: \"EndpointParams\")) else {", "}", SmithyTypes.AttributeKey) { + openBlock("guard let endpointParam = context.get(key: \$N(name: \"EndpointParams\")) else {", "}", SmithyTypes.AttributeKey) { write("throw \$N.dataNotFound(\"Endpoint param not configured in middleware context for rules-based auth scheme resolver params construction.\")", SmithyTypes.ClientError) } diff --git a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/middleware/OperationEndpointResolverMiddleware.kt b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/middleware/OperationEndpointResolverMiddleware.kt index b3629632938..47f7a97edd4 100644 --- a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/middleware/OperationEndpointResolverMiddleware.kt +++ b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/middleware/OperationEndpointResolverMiddleware.kt @@ -52,7 +52,7 @@ class OperationEndpointResolverMiddleware( // Write code that saves endpoint params to middleware context for use in auth scheme middleware when using rules-based auth scheme resolvers if (AuthSchemeResolverGenerator.usesRulesBasedAuthResolver(ctx)) { - writer.write("context.attributes.set(key: \$N(name: \"EndpointParams\"), value: endpointParams)", SmithyTypes.AttributeKey) + writer.write("context.set(key: \$N(name: \"EndpointParams\"), value: endpointParams)", SmithyTypes.AttributeKey) } super.renderSpecific(ctx, writer, op, operationStackName, "applyEndpoint") diff --git a/codegen/smithy-aws-swift-codegen/src/test/kotlin/software/amazon/smithy/aws/swift/codegen/PresignerGeneratorTests.kt b/codegen/smithy-aws-swift-codegen/src/test/kotlin/software/amazon/smithy/aws/swift/codegen/PresignerGeneratorTests.kt index eb8d48e3009..f77543ec680 100644 --- a/codegen/smithy-aws-swift-codegen/src/test/kotlin/software/amazon/smithy/aws/swift/codegen/PresignerGeneratorTests.kt +++ b/codegen/smithy-aws-swift-codegen/src/test/kotlin/software/amazon/smithy/aws/swift/codegen/PresignerGeneratorTests.kt @@ -270,7 +270,7 @@ extension PutObjectInput { builder.retryErrorInfoProvider(AWSClientRuntime.AWSRetryErrorInfoProvider.errorInfo(for:)) builder.applySigner(ClientRuntime.SignerMiddleware()) let endpointParams = EndpointParams() - context.attributes.set(key: Smithy.AttributeKey(name: "EndpointParams"), value: endpointParams) + context.set(key: Smithy.AttributeKey(name: "EndpointParams"), value: endpointParams) builder.applyEndpoint(AWSClientRuntime.EndpointResolverMiddleware(endpointResolverBlock: { [config] in try config.endpointResolver.resolve(params: ${'$'}0) }, endpointParams: endpointParams)) builder.interceptors.add(AWSClientRuntime.UserAgentMiddleware(serviceID: serviceName, version: S3Client.version, config: config)) builder.selectAuthScheme(ClientRuntime.AuthSchemeMiddleware()) diff --git a/codegen/smithy-aws-swift-codegen/src/test/kotlin/software/amazon/smithy/aws/swift/codegen/customizations/RulesBasedAuthSchemeResolverGeneratorTests.kt b/codegen/smithy-aws-swift-codegen/src/test/kotlin/software/amazon/smithy/aws/swift/codegen/customizations/RulesBasedAuthSchemeResolverGeneratorTests.kt index 7109a510abb..c68875ea213 100644 --- a/codegen/smithy-aws-swift-codegen/src/test/kotlin/software/amazon/smithy/aws/swift/codegen/customizations/RulesBasedAuthSchemeResolverGeneratorTests.kt +++ b/codegen/smithy-aws-swift-codegen/src/test/kotlin/software/amazon/smithy/aws/swift/codegen/customizations/RulesBasedAuthSchemeResolverGeneratorTests.kt @@ -129,7 +129,7 @@ public struct DefaultS3AuthSchemeResolver: S3AuthSchemeResolver { guard let opName = context.getOperation() else { throw Smithy.ClientError.dataNotFound("Operation name not configured in middleware context for auth scheme resolver params construction.") } - guard let endpointParam = context.attributes.get(key: Smithy.AttributeKey(name: "EndpointParams")) else { + guard let endpointParam = context.get(key: Smithy.AttributeKey(name: "EndpointParams")) else { throw Smithy.ClientError.dataNotFound("Endpoint param not configured in middleware context for rules-based auth scheme resolver params construction.") } return S3AuthSchemeResolverParameters(operation: opName)