public T withS3PresignerShuttingDownImmediately()

in s3-artifact-storage-server/src/main/java/jetbrains/buildServer/artifacts/s3/amazonClient/impl/AmazonS3ProviderImpl.java [371:413]


  public  <T, E extends Exception> T withS3PresignerShuttingDownImmediately(@NotNull final String bucket,
                                                                            @NotNull final Map<String, String> params,
                                                                            @NotNull final String projectId,
                                                                            @NotNull final WithS3Presigner<T, E> withS3Presigner)
    throws ConnectionCredentialsException {
    final Map<String, String> correctedSettings = getCorrectedRegionAndAcceleration(bucket, params, projectId);
    if (ParamUtil.withAwsConnectionId(correctedSettings)) {
      S3Presigner s3Presigner = presignerFromS3Settings(correctedSettings, projectId);
      try {
        return withS3Presigner.execute(s3Presigner);
      } catch (Exception e) {
        throw new ConnectionCredentialsException(e);
      } finally {
        shutdownPresigner(s3Presigner);
      }
    } else {
      try {
        return AWSCommonParams.withAWSClients(correctedSettings, clients -> {
          final AwsCredentials credentials = clients.getCredentials();
          if (credentials == null) {
            throw new ConnectionCredentialsException("Cannot generate presigned url, no AWS credentials provided");
          }
          final S3Presigner s3Presigner = S3Presigner.builder()
                                                     .region(Region.of(clients.getRegion()))
                                                     .credentialsProvider(StaticCredentialsProvider.create(credentials))
                                                     .serviceConfiguration(
                                                       S3Configuration.builder()
                                                                      .accelerateModeEnabled(isAccelerateModeEnabled(correctedSettings))
                                                                      .pathStyleAccessEnabled(!disablePathStyleAccess(correctedSettings))
                                                                      .build()
                                                     )
                                                     .build();
          try {
            return withS3Presigner.execute(s3Presigner);
          } finally {
            shutdownPresigner(s3Presigner);
          }
        });
      } catch (Throwable t) {
        throw new ConnectionCredentialsException(new Exception(t));
      }
    }
  }