Skip to content

Commit

Permalink
Fix AuthSchemes not remaining ordered (#1591)
Browse files Browse the repository at this point in the history
* Ensure authSchemes retain order

* Switch to using a sorted Map for authscheme properties to ensure they always maintain a stable order and not rely on input to be stable
  • Loading branch information
alextwoods authored Jan 25, 2023
1 parent 81b3e44 commit a39e81b
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.TreeMap;
import java.util.stream.Collectors;
import software.amazon.smithy.model.FromSourceLocation;
import software.amazon.smithy.model.SourceLocation;
Expand Down Expand Up @@ -71,7 +73,8 @@ private Endpoint(Builder builder) {
builder.authSchemes.copy().stream()
.map(
authScheme -> {
Map<Identifier, Literal> base = new LinkedHashMap<>();
Map<Identifier, Literal> base = new TreeMap<>(
Comparator.comparing(Identifier::asString));
base.put(Identifier.of("name"), Literal.of(authScheme.left.asString()));
base.putAll(authScheme.right);
return Literal.record(base);
Expand Down

0 comments on commit a39e81b

Please sign in to comment.