private static String extractCorrectedRegion()

in teamcity-s3-sdk/src/main/java/jetbrains/buildServer/artifacts/s3/S3Util.java [487:496]


  private static String extractCorrectedRegion(@NotNull final Throwable e) {
    @Nullable final S3Exception awsException = e instanceof S3Exception ? (S3Exception)e : ExceptionUtil.getCause(e, S3Exception.class);
    if (awsException != null && TeamCityProperties.getBooleanOrTrue("teamcity.internal.storage.s3.autoCorrectRegion") && awsException.awsErrorDetails() != null) {
      final SdkHttpResponse response = awsException.awsErrorDetails().sdkHttpResponse();
      if (response != null) {
        return response.firstMatchingHeader("x-amz-bucket-region").orElseGet(() -> extractRegionIfMalformedHeaderException(awsException));
      }
    }
    return null;
  }