1717
1818import java .util .ArrayList ;
1919import java .util .HashMap ;
20+ import java .util .LinkedHashMap ;
2021import java .util .List ;
2122import java .util .Map ;
23+ import java .util .function .Function ;
24+ import java .util .stream .Collectors ;
2225import software .amazon .awssdk .annotations .Immutable ;
2326import software .amazon .awssdk .annotations .SdkInternalApi ;
2427import software .amazon .awssdk .identity .spi .Identity ;
3538@ Immutable
3639@ SdkInternalApi
3740public final class DefaultIdentityProviders implements IdentityProviders {
38- /**
39- * TODO(sra-identity-auth): Currently, some customers assume we won't interact with the identity providers when we create
40- * the client. This isn't true - we need to call identityType. To TEMPORARILY work around those customer's tests failing,
41- * this is marked lazy. Once we fully migrate over to the SRA as the default code path, we should remove this lazy and
42- * ticket everyone in live who is making those bad assumptions.
43- */
44- private final Lazy < Map <Class <?>, IdentityProvider <?> >> identityProviders ;
41+ // / **
42+ // * TODO(sra-identity-auth): Currently, some customers assume we won't interact with the identity providers when we create
43+ // * the client. This isn't true - we need to call identityType. To TEMPORARILY work around those customer's tests failing,
44+ // * this is marked lazy. Once we fully migrate over to the SRA as the default code path, we should remove this lazy and
45+ // * ticket everyone in live who is making those bad assumptions.
46+ // */
47+ private final Map <Class <?>, IdentityProvider <?>> identityProviders ;
4548 private final List <IdentityProvider <?>> identityProvidersList ;
4649
4750 private DefaultIdentityProviders (BuilderImpl builder ) {
4851 this .identityProvidersList = new ArrayList <>(builder .identityProviders );
49- this .identityProviders = new Lazy <>(() -> {
50- Map <Class <?>, IdentityProvider <?>> result = new HashMap <>();
51- for (IdentityProvider <?> identityProvider : identityProvidersList ) {
52- result .put (identityProvider .identityType (), identityProvider );
53- }
54- return result ;
55- });
52+ this .identityProviders = identityProvidersList .stream ().collect (
53+ Collectors .toMap (identityProvider -> identityProvider .identityType (),
54+ Function .identity ()));
5655 }
5756
5857 public static Builder builder () {
@@ -61,7 +60,7 @@ public static Builder builder() {
6160
6261 @ Override
6362 public <T extends Identity > IdentityProvider <T > identityProvider (Class <T > identityType ) {
64- return (IdentityProvider <T >) identityProviders .getValue (). get (identityType );
63+ return (IdentityProvider <T >) identityProviders .get (identityType );
6564 }
6665
6766 @ Override
0 commit comments