Skip to content

Commit af146f4

Browse files
author
Rishabh Jain
committed
fix(s3): preserve original cause in ParallelMultipartDownloaderSubscriber.onError
onError cancelled in-flight part requests before completing resultFuture with the failure cause. The cancel loop races a CancellationException onto resultFuture (via the forwardExceptionTo wiring), so callers observing the download's completion future saw a bare CancellationException with no root cause. The trigger was also never logged. Complete resultFuture with the original throwable first, then cancel, and log the cause at debug level, matching the sibling ParallelPresignedUrlMultipartDownloaderSubscriber.
1 parent f3ea4fc commit af146f4

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"type": "bugfix",
3+
"category": "Amazon S3",
4+
"contributor": "rishabhjainps",
5+
"description": "Fixed an issue in multipart download where a failed download could surface a bare CancellationException with no root cause. ParallelMultipartDownloaderSubscriber.onError now completes the result future with the original throwable before cancelling in-flight part requests, matching the sibling ParallelPresignedUrlMultipartDownloaderSubscriber, and logs the cause at debug level."
6+
}

services/s3/src/main/java/software/amazon/awssdk/services/s3/internal/multipart/ParallelMultipartDownloaderSubscriber.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,12 @@ private boolean shouldProcessPendingTransformers() {
412412

413413
@Override
414414
public void onError(Throwable t) {
415-
// Signal received from the publisher this is subscribed to
416-
// (in the case of file download, that's FileAsyncResponseTransformerPublisher)
417-
// Failed state, something really wrong has happened, cancel everything
415+
// Complete the result future with the original cause before cancelling in-flight parts.
416+
// Cancelling first races a CancellationException onto resultFuture and masks t.
417+
log.debug(() -> "Error in parallel multipart download", t);
418+
resultFuture.completeExceptionally(t);
418419
inFlightRequests.values().forEach(future -> future.cancel(true));
419420
inFlightRequests.clear();
420-
resultFuture.completeExceptionally(t);
421421
}
422422

423423
@Override

0 commit comments

Comments
 (0)