public S3PresignedUpload()

in teamcity-s3-sdk/src/main/java/jetbrains/buildServer/artifacts/s3/publish/presigned/upload/S3PresignedUpload.java [71:125]


  public S3PresignedUpload(@NotNull final String artifactPath,
                           @NotNull final String objectKey,
                           @NotNull final File file,
                           @NotNull final S3Util.S3AdvancedConfiguration configuration,
                           @NotNull final S3SignedUploadManager s3SignedUploadManager,
                           @NotNull final LowLevelS3Client lowLevelS3Client,
                           @NotNull final PresignedUploadProgressListener progressListener) {
    myArtifactPath = artifactPath;
    myObjectKey = objectKey;
    myFile = file;
    myS3SignedUploadManager = s3SignedUploadManager;
    myLowLevelS3Client = lowLevelS3Client;
    myProgressListener = progressListener;
    // initialize TTL with value from configuration. without this line, default TTL will be used for the first PUT request.
    if (myTtl.get() == null) {
      myTtl.set((long)configuration.getUrlTtlSeconds());
    }
    myRetrier = Retrier.withRetries(configuration.getRetriesNum(), Retrier.DelayStrategy.linearBackOff(configuration.getRetryDelay()))
                       .registerListener(new LoggingRetrierListener(LOGGER))
                       .registerListener(
                         new AbortingListener(arrayOfRetriableErrors) {
                           @Override
                           public <T> void onFailure(@NotNull   Callable<T> callable, int retry, @NotNull Exception failure) {
                             Exception e = stripRootCause(failure);

                             if (S3SignedUrlFileUploader.isPublishingInterruptedException(e) ||
                                 // a broken pipe means that the server closed connection
                                 // in some cases it means that expiration date already passed
                                 // it is better to re-generate the request
                                 (e instanceof SocketException && e.getMessage() != null && e.getMessage().contains("Broken pipe"))) {
                               throw new AbortRetriesException(e);
                             }
                             if (e instanceof HttpClientUtil.HttpErrorCodeException) {
                               if (((HttpClientUtil.HttpErrorCodeException)e).getResponseCode() == 403 && e.getMessage().contains("Request has expired")) {
                                 final Long prev = myTtl.get();
                                 // null check for safety
                                 if (prev == null) {
                                   myTtl.set(Long.min(2L * configuration.getUrlTtlSeconds(), S3Constants.S3_AMAZON_REQUEST_TIMEOUT_CAP_IN_SECONDS));
                                 } else {
                                   myTtl.set(Long.min(2L * prev, S3Constants.S3_AMAZON_REQUEST_TIMEOUT_CAP_IN_SECONDS));
                                 }
                               } else if (isRecoverable(e)) {
                                 // recoverable error, retry
                                 return;
                               }

                               throw new AbortRetriesException(e);
                             }

                             super.onFailure(callable, retry, e);
                           }
                         });

    progressListener.setUpload(this);
  }