-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Motivation and Context Fixes #2944 ## Description `CustomizableOperation` in the last two releases ([release-2023-08-01](https://github.com/awslabs/smithy-rs/releases/tag/release-2023-08-01) and [release-2023-08-22](https://github.com/awslabs/smithy-rs/releases/tag/release-2023-08-22)) broke backward-compatibility with respect to its auto traits. Specifically, it ceased to be `Send` and `Sync` because the struct contained a boxed trait object. This PR fix that issue, making `CustomizableOperation` `Send` and `Sync` again. ## Testing - Added a Kotlin unit test to verify `CustomizableOperation` is `Send` and `Sync`. ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [x] I have updated `CHANGELOG.next.toml` if I made changes to the smithy-rs codegen or runtime crates - [x] I have updated `CHANGELOG.next.toml` if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --------- Co-authored-by: ysaito1001 <[email protected]>
- Loading branch information
1 parent
997c9c8
commit cf95f48
Showing
4 changed files
with
155 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
...smithy/rust/codegen/client/smithy/generators/client/CustomizableOperationGeneratorTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package software.amazon.smithy.rust.codegen.client.smithy.generators.client | ||
|
||
import org.junit.jupiter.api.Test | ||
import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext | ||
import software.amazon.smithy.rust.codegen.client.testutil.TestCodegenSettings | ||
import software.amazon.smithy.rust.codegen.client.testutil.clientIntegrationTest | ||
import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency | ||
import software.amazon.smithy.rust.codegen.core.rustlang.rust | ||
import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate | ||
import software.amazon.smithy.rust.codegen.core.rustlang.writable | ||
import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType | ||
import software.amazon.smithy.rust.codegen.core.smithy.RustCrate | ||
import software.amazon.smithy.rust.codegen.core.testutil.asSmithyModel | ||
import software.amazon.smithy.rust.codegen.core.testutil.integrationTest | ||
|
||
class CustomizableOperationGeneratorTest { | ||
val model = """ | ||
namespace com.example | ||
use aws.protocols#awsJson1_0 | ||
@awsJson1_0 | ||
service HelloService { | ||
operations: [SayHello], | ||
version: "1" | ||
} | ||
@optionalAuth | ||
operation SayHello { input: TestInput } | ||
structure TestInput { | ||
foo: String, | ||
} | ||
""".asSmithyModel() | ||
|
||
@Test | ||
fun `CustomizableOperation is send and sync`() { | ||
val test: (ClientCodegenContext, RustCrate) -> Unit = { codegenContext, rustCrate -> | ||
rustCrate.integrationTest("customizable_operation_is_send_and_sync") { | ||
val moduleName = codegenContext.moduleUseName() | ||
rustTemplate( | ||
""" | ||
fn check_send_and_sync<T: Send + Sync>(_: T) {} | ||
##[test] | ||
fn test() { | ||
let connector = #{TestConnection}::<#{SdkBody}>::new(Vec::new()); | ||
let config = $moduleName::Config::builder() | ||
.endpoint_resolver("http://localhost:1234") | ||
#{set_http_connector} | ||
.build(); | ||
let smithy_client = aws_smithy_client::Builder::new() | ||
.connector(connector.clone()) | ||
.middleware_fn(|r| r) | ||
.build_dyn(); | ||
let client = $moduleName::Client::with_config(smithy_client, config); | ||
check_send_and_sync(client.say_hello().customize()); | ||
} | ||
""", | ||
"TestConnection" to CargoDependency.smithyClient(codegenContext.runtimeConfig) | ||
.toDevDependency() | ||
.withFeature("test-util").toType() | ||
.resolve("test_connection::TestConnection"), | ||
"SdkBody" to RuntimeType.sdkBody(codegenContext.runtimeConfig), | ||
"set_http_connector" to writable { | ||
if (codegenContext.smithyRuntimeMode.generateOrchestrator) { | ||
rust(".http_connector(connector.clone())") | ||
} | ||
}, | ||
) | ||
} | ||
} | ||
clientIntegrationTest(model, TestCodegenSettings.middlewareModeTestParams, test = test) | ||
clientIntegrationTest( | ||
model, | ||
TestCodegenSettings.orchestratorModeTestParams, | ||
test = test, | ||
) | ||
} | ||
} |