public override bool RetryForException(Runtime.IExecutionContext executionContext, Exception exception)
{
var syncResult = RetryForExceptionSync(executionContext, exception);
if (syncResult.HasValue)
{
return syncResult.Value;
}
else
{
var serviceException = exception as AmazonServiceException;
string correctedRegion = null;
AmazonS3Uri s3BucketUri;
if (AmazonS3Uri.TryParseAmazonS3Uri(executionContext.RequestContext.Request.Endpoint, out s3BucketUri))
{
var credentials = executionContext.RequestContext.ImmutableCredentials;
if (credentials != null)
{
correctedRegion = BucketRegionDetector.DetectMismatchWithHeadBucketFallback(s3BucketUri, serviceException, credentials);
}
}
if (correctedRegion == null)
{
return base.RetryForException(executionContext, exception);
}
else
{
// change authentication region of request and signal the handler to sign again with the new region
executionContext.RequestContext.Request.AuthenticationRegion = correctedRegion;
executionContext.RequestContext.IsSigned = false;
return true;
}
}
}
}