Skip to content

Commit

Permalink
Log exception, and handle null region outside of catch block
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Dines committed Feb 24, 2019
1 parent 444c6a6 commit 3b26433
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,16 @@ public AWSCredentials getCredentials() {
return initialCredentials;
} else {
// Check for available region from the SDK, otherwise specify default
String clientRegion;
String clientRegion = null;
DefaultAwsRegionProviderChain sdkRegionLookup = new DefaultAwsRegionProviderChain();
try {
clientRegion = sdkRegionLookup.getRegion();
}
catch(com.amazonaws.SdkClientException e) {
if (e.getMessage() == "Unable to load region information from any provider in the chain") {
clientRegion = Regions.DEFAULT_REGION.getName();
} else {
throw e;
}
LOGGER.log(Level.WARNING,"Could not find default region using SDK lookup.", e);
}
if (clientRegion == null) {
clientRegion = Regions.DEFAULT_REGION.getName();
}

AWSSecurityTokenService client;
Expand Down

0 comments on commit 3b26433

Please sign in to comment.