code: public void setSpaceLifecycle(String bucketName,
                                    BucketLifecycleConfiguration config) {
          boolean success = false;
          int maxLoops = 6;
          for (int loops = 0; !success && loops < maxLoops; loops++) {
              try {
                  s3Client.deleteBucketLifecycleConfiguration(bucketName);
                  s3Client.setBucketLifecycleConfiguration(bucketName, config);
                  success = true;
              } catch (NotFoundException e) {
                  success = false;
                  wait(loops);
              }
          }
  
          if (!success) {
              throw new StorageException(
                  "Lifecycle policy for bucket " + bucketName +
                  " could not be applied. The space cannot be found.");
          }
      }
docs: Sets a lifecycle policy on an S3 bucket based on the given configuration
  
  @param bucketName name of the bucket to update
  @param config     bucket lifecycle configuration