From a5c1da3b1b050cbcf159ef98db3f0d204e613d90 Mon Sep 17 00:00:00 2001 From: Thor Bjorgvinsson Date: Mon, 29 May 2023 12:29:34 -0400 Subject: [PATCH 1/2] Fix tiny_map from_iter where one operation was being dropped --- CHANGELOG.next.toml | 6 ++++++ .../src/routing/tiny_map.rs | 16 +++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index 51319b5986..f38acac11b 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -11,6 +11,12 @@ # meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client | server | all"} # author = "rcoh" +[[smithy-rs]] +message = "Fix tiny_map from_iter where one operation was being dropped" +author = "thor-bjorgvinsson" +references = ["smithy-rs#2733"] +meta = { "breaking" = false, "tada" = false, "bug" = true, "target" ="server" } + [[aws-sdk-rust]] message = "Remove native-tls and add a migration guide." author = "82marbag" diff --git a/rust-runtime/aws-smithy-http-server/src/routing/tiny_map.rs b/rust-runtime/aws-smithy-http-server/src/routing/tiny_map.rs index 236da27797..7011515641 100644 --- a/rust-runtime/aws-smithy-http-server/src/routing/tiny_map.rs +++ b/rust-runtime/aws-smithy-http-server/src/routing/tiny_map.rs @@ -78,13 +78,13 @@ where // Populate the `Vec` while let Some((index, pair)) = iter.next() { + vec.push(pair); + // If overflow `CUTOFF` then return a `HashMap` instead if index == CUTOFF { let inner = TinyMapInner::HashMap(vec.into_iter().chain(iter.map(|(_, pair)| pair)).collect()); return TinyMap { inner }; } - - vec.push(pair); } TinyMap { @@ -158,19 +158,25 @@ mod tests { #[test] fn get_small_success() { let tiny_map: TinyMap<_, _, CUTOFF> = SMALL_VALUES.into_iter().collect(); - assert_eq!(tiny_map.get("a"), Some(&0)) + SMALL_VALUES.into_iter().for_each(|(op, val)| { + assert_eq!(tiny_map.get(op), Some(&val)); + }); } #[test] fn get_medium_success() { let tiny_map: TinyMap<_, _, CUTOFF> = MEDIUM_VALUES.into_iter().collect(); - assert_eq!(tiny_map.get("d"), Some(&3)) + MEDIUM_VALUES.into_iter().for_each(|(op, val)| { + assert_eq!(tiny_map.get(op), Some(&val)); + }); } #[test] fn get_large_success() { let tiny_map: TinyMap<_, _, CUTOFF> = LARGE_VALUES.into_iter().collect(); - assert_eq!(tiny_map.get("h"), Some(&7)) + LARGE_VALUES.into_iter().for_each(|(op, val)| { + assert_eq!(tiny_map.get(op), Some(&val)); + }); } #[test] From c297217855f2f57b772d2853e1607e2cc24a37e0 Mon Sep 17 00:00:00 2001 From: Thor Bjorgvinsson <64786777+Thor-Bjorgvinsson@users.noreply.github.com> Date: Mon, 29 May 2023 13:59:13 -0400 Subject: [PATCH 2/2] Update CHANGELOG.next.toml Co-authored-by: david-perez --- CHANGELOG.next.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index f38acac11b..c3f9bd4d7c 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -12,7 +12,7 @@ # author = "rcoh" [[smithy-rs]] -message = "Fix tiny_map from_iter where one operation was being dropped" +message = "Fix bug in AWS JSON 1.x routers where, if a service had more than 14 operations, the router was created without the route for the 15th operation." author = "thor-bjorgvinsson" references = ["smithy-rs#2733"] meta = { "breaking" = false, "tada" = false, "bug" = true, "target" ="server" }