Skip to content

Commit 332be8e

Browse files
CR suggestions
1 parent 56f28e5 commit 332be8e

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/main/java/net/snowflake/client/core/auth/wif/AWSAttestationService.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
@SnowflakeJdbcInternalApi
1616
public class AWSAttestationService {
1717

18-
private static final AWS4Signer aws4Signer;
18+
private static boolean regionInitialized = false;
19+
private static String region;
1920

20-
static {
21+
private final AWS4Signer aws4Signer;
22+
23+
public AWSAttestationService() {
2124
aws4Signer = new AWS4Signer();
2225
aws4Signer.setServiceName("sts");
2326
}
@@ -27,12 +30,12 @@ AWSCredentials getAWSCredentials() {
2730
}
2831

2932
String getAWSRegion() {
30-
String region = SnowflakeUtil.systemGetEnv("AWS_REGION");
31-
if (region != null) {
32-
return region;
33-
} else {
34-
return new InstanceMetadataRegionProvider().getRegion();
33+
if (!regionInitialized) {
34+
String envRegion = SnowflakeUtil.systemGetEnv("AWS_REGION");
35+
region = envRegion != null ? envRegion : new InstanceMetadataRegionProvider().getRegion();
36+
regionInitialized = true;
3537
}
38+
return region;
3639
}
3740

3841
String getArn() {

0 commit comments

Comments
 (0)