Skip to content

Commit

Permalink
Revert "fix: stop adding serde middleware repeatedly (smithy-lang#259)"
Browse files Browse the repository at this point in the history
This reverts commit c57cca3.

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.
  • Loading branch information
AllanZhengYP committed Jan 27, 2021
1 parent c57cca3 commit 894b5ab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ public void addsCommandSpecificPlugins() {
" configuration: ExampleClientResolvedConfig,\n" +
" options?: __HttpHandlerOptions\n" +
" ): Handler<GetFooCommandInput, GetFooCommandOutput> {\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);");
}
Expand Down

0 comments on commit 894b5ab

Please sign in to comment.