Skip to content

Commit 6e0ec6f

Browse files
AllanZhengYPsrchase
authored andcommitted
Revert "fix: stop adding serde middleware repeatedly (smithy-lang#259)" (smithy-lang#267)
This reverts commit c57cca3. If a command instance is used by a different 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 smithy-lang#259 is no longer needed.
1 parent 41211f8 commit 6e0ec6f

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CommandGenerator.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ public void run() {
104104
writer.writeShapeDocs(operation);
105105
writer.openBlock("export class $L extends $$Command<$T, $T, $L> {", "}", name, inputType, outputType,
106106
configType, () -> {
107-
writer.write("private resolved = false;");
108107

109108
// Section for adding custom command properties.
110109
writer.write("// Start section: $L", COMMAND_PROPERTIES_SECTION);
@@ -146,15 +145,11 @@ private void generateCommandMiddlewareResolver(String configType) {
146145
.write("options?: $T", applicationProtocol.getOptionsType())
147146
.dedent();
148147
writer.openBlock("): Handler<$T, $T> {", "}", inputType, outputType, () -> {
149-
writer.openBlock("if (!this.resolved) {", "}", () -> {
150-
// Add serialization and deserialization plugin.
151-
writer.write("this.middlewareStack.use($T(configuration, this.serialize, this.deserialize));", serde);
148+
// Add serialization and deserialization plugin.
149+
writer.write("this.middlewareStack.use($T(configuration, this.serialize, this.deserialize));", serde);
152150

153-
// Add customizations.
154-
addCommandSpecificPlugins();
155-
156-
writer.write("this.resolved = true;");
157-
});
151+
// Add customizations.
152+
addCommandSpecificPlugins();
158153

159154
// Resolve the middleware stack.
160155
writer.write("\nconst stack = clientStack.concat(this.middlewareStack);\n");

smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/CommandGeneratorTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ public void addsCommandSpecificPlugins() {
1818
" configuration: ExampleClientResolvedConfig,\n" +
1919
" options?: __HttpHandlerOptions\n" +
2020
" ): Handler<GetFooCommandInput, GetFooCommandOutput> {\n" +
21-
" if (!this.resolved) {\n" +
22-
" this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));\n" +
23-
" this.resolved = true;\n" +
24-
" }\n" +
21+
" this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));\n" +
2522
"\n" +
2623
" const stack = clientStack.concat(this.middlewareStack);");
2724
}

0 commit comments

Comments
 (0)