File tree Expand file tree Collapse file tree 3 files changed +9
-10
lines changed
auth/src/main/java/software/amazon/awssdk/auth/credentials
regions/src/test/java/software/amazon/awssdk/regions/internal/util Expand file tree Collapse file tree 3 files changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -89,8 +89,6 @@ public final class InstanceProfileCredentialsProvider
89
89
private final Supplier <ProfileFile > profileFile ;
90
90
91
91
private final String profileName ;
92
- private final Object lock = new Object ();
93
- private volatile Boolean isInsecureFallbackDisabled ;
94
92
95
93
/**
96
94
* @see #builder()
@@ -273,14 +271,7 @@ private String handleTokenErrorResponse(Exception e) {
273
271
}
274
272
275
273
private boolean isInsecureFallbackDisabled () {
276
- if (isInsecureFallbackDisabled == null ) {
277
- synchronized (lock ) {
278
- if (isInsecureFallbackDisabled == null ) {
279
- isInsecureFallbackDisabled = ec2MetadataDisableV1Resolver .resolve ();
280
- }
281
- }
282
- }
283
- return isInsecureFallbackDisabled ;
274
+ return ec2MetadataDisableV1Resolver .resolve ();
284
275
}
285
276
286
277
private String [] getSecurityCredentials (String imdsHostname , String metadataToken ) {
Original file line number Diff line number Diff line change 21
21
import software .amazon .awssdk .core .SdkSystemSetting ;
22
22
import software .amazon .awssdk .profiles .ProfileFile ;
23
23
import software .amazon .awssdk .profiles .ProfileProperty ;
24
+ import software .amazon .awssdk .utils .Lazy ;
24
25
import software .amazon .awssdk .utils .OptionalUtils ;
25
26
26
27
@ SdkInternalApi
27
28
public final class Ec2MetadataDisableV1Resolver {
28
29
private final Supplier <ProfileFile > profileFile ;
29
30
private final String profileName ;
31
+ private final Lazy <Boolean > resolvedValue ;
30
32
31
33
private Ec2MetadataDisableV1Resolver (Supplier <ProfileFile > profileFile , String profileName ) {
32
34
this .profileFile = profileFile ;
33
35
this .profileName = profileName ;
36
+ this .resolvedValue = new Lazy <>(this ::doResolve );
34
37
}
35
38
36
39
public static Ec2MetadataDisableV1Resolver create (Supplier <ProfileFile > profileFile , String profileName ) {
37
40
return new Ec2MetadataDisableV1Resolver (profileFile , profileName );
38
41
}
39
42
40
43
public boolean resolve () {
44
+ return resolvedValue .getValue ();
45
+ }
46
+
47
+ public boolean doResolve () {
41
48
return OptionalUtils .firstPresent (fromSystemSettings (),
42
49
() -> fromProfileFile (profileFile , profileName ))
43
50
.orElse (false );
Original file line number Diff line number Diff line change 26
26
import static org .assertj .core .api .Assertions .assertThat ;
27
27
28
28
import com .github .tomakehurst .wiremock .client .WireMock ;
29
+ import com .github .tomakehurst .wiremock .http .Fault ;
29
30
import com .github .tomakehurst .wiremock .junit .WireMockRule ;
30
31
import org .junit .Before ;
31
32
import org .junit .Rule ;
You can’t perform that action at this time.
0 commit comments