/** * Wait for an upload to complete. * If the waiting for completion is interrupted, the upload will be * aborted before an {@code InterruptedIOException} is thrown. * @param upload upload to wait for * @param key destination key * @return the upload result * @throws InterruptedIOException if the blocking was interrupted. */ UploadResult waitForUploadCompletion(String key, UploadInfo uploadInfo) throws InterruptedIOException { Upload upload = uploadInfo.getUpload(); try { UploadResult result = upload.waitForUploadResult(); incrementPutCompletedStatistics(true, uploadInfo.getLength()); return result; } catch (InterruptedException e) { LOG.info("Interrupted: aborting upload"); incrementPutCompletedStatistics(false, uploadInfo.getLength()); upload.abort(); throw (InterruptedIOException) new InterruptedIOException("Interrupted in PUT to " + keyToQualifiedPath(key)) .initCause(e); } }