From 894b5ab2e19f9573c9bfb0fa6239f54f5397ff37 Mon Sep 17 00:00:00 2001 From: AllanZhengYP Date: Wed, 27 Jan 2021 06:33:07 +0000 Subject: [PATCH] Revert "fix: stop adding serde middleware repeatedly (#259)" This reverts commit c57cca31d2216849ef123d19b86ea0fab6eb12d4. client instance, the command still consumes the configuration of the previous client interface. This issue is resolved by allowing adding middleware to the stack without throwing error. So #259 is no longer needed. --- .../smithy/typescript/codegen/CommandGenerator.java | 13 ++++--------- .../typescript/codegen/CommandGeneratorTest.java | 5 +---- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CommandGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CommandGenerator.java index 39c930fa6d3..c5f5947ddbc 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CommandGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CommandGenerator.java @@ -104,7 +104,6 @@ public void run() { writer.writeShapeDocs(operation); writer.openBlock("export class $L extends $$Command<$T, $T, $L> {", "}", name, inputType, outputType, configType, () -> { - writer.write("private resolved = false;"); // Section for adding custom command properties. writer.write("// Start section: $L", COMMAND_PROPERTIES_SECTION); @@ -146,15 +145,11 @@ private void generateCommandMiddlewareResolver(String configType) { .write("options?: $T", applicationProtocol.getOptionsType()) .dedent(); writer.openBlock("): Handler<$T, $T> {", "}", inputType, outputType, () -> { - writer.openBlock("if (!this.resolved) {", "}", () -> { - // Add serialization and deserialization plugin. - writer.write("this.middlewareStack.use($T(configuration, this.serialize, this.deserialize));", serde); + // Add serialization and deserialization plugin. + writer.write("this.middlewareStack.use($T(configuration, this.serialize, this.deserialize));", serde); - // Add customizations. - addCommandSpecificPlugins(); - - writer.write("this.resolved = true;"); - }); + // Add customizations. + addCommandSpecificPlugins(); // Resolve the middleware stack. writer.write("\nconst stack = clientStack.concat(this.middlewareStack);\n"); diff --git a/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/CommandGeneratorTest.java b/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/CommandGeneratorTest.java index ca22a49e6c3..a2468ba1a04 100644 --- a/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/CommandGeneratorTest.java +++ b/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/CommandGeneratorTest.java @@ -18,10 +18,7 @@ public void addsCommandSpecificPlugins() { " configuration: ExampleClientResolvedConfig,\n" + " options?: __HttpHandlerOptions\n" + " ): Handler {\n" + - " if (!this.resolved) {\n" + - " this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));\n" + - " this.resolved = true;\n" + - " }\n" + + " this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));\n" + "\n" + " const stack = clientStack.concat(this.middlewareStack);"); }