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);"); }