private T withS3Client()

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


  private <T, E extends Exception> T withS3Client(@NotNull final Map<String, String> params,
                                                  @NotNull final String projectId,
                                                  @NotNull final WithS3Client<T, E> withS3Client, boolean shutdownImmediately) throws ConnectionCredentialsException {

    final Map<String, String> correctedSettings = extractCachedCorrectedSettings(params, projectId);
    if (ParamUtil.withAwsConnectionId(correctedSettings)) {
      S3Client s3Client = fromS3Settings(correctedSettings, projectId);
      try {
        return withS3Client.execute(s3Client);
      } catch (Exception e) {
        throw new ConnectionCredentialsException(e);
      } finally {
        if (shutdownImmediately) {
          shutdownClient(s3Client);
        }
      }
    } else {
      try {
        //todo shouldn't be merged unless this branch is supported
        //to think about of converging both paths (need to sep static creds vs session ones)
        //better to move it to this plugin instead of leaving it in the AWS Core
        return AWSCommonParams.withAWSClients(correctedSettings, clients -> {
          clients.setS3SignerType(S3_SIGNER_TYPE);
          clients.setDisablePathStyleAccess(disablePathStyleAccess(correctedSettings));
          clients.setAccelerateModeEnabled(isAccelerateModeEnabled(correctedSettings));
          patchAWSClientsSsl(clients, correctedSettings);
          final S3Client s3Client = clients.createS3Client();
          try {
            return withS3Client.execute(s3Client);
          } finally {
            if (shutdownImmediately) {
              S3Util.shutdownClient(s3Client);
            }
          }
        });
      } catch (Throwable t) {
        throw new ConnectionCredentialsException(new Exception(t));
      }
    }
  }