fix(s3): preserve original cause in ParallelMultipartDownloaderSubscriber.onError#7175
Open
rishabhjainps wants to merge 1 commit into
Open
Conversation
…iber.onError onError cancelled the in-flight part requests before completing resultFuture with the failure cause. Each part future is wired to resultFuture via CompletableFutureUtils.forwardExceptionTo, so cancelling first raced a CancellationException onto resultFuture and discarded the original cause; callers observing the download's completion future saw a bare CancellationException with no root cause, and the trigger was never logged. Complete resultFuture with the original throwable first, then cancel the in-flight parts, and log the cause at debug level, matching the sibling ParallelPresignedUrlMultipartDownloaderSubscriber. Add a unit test covering the onError cause-preservation ordering.
rishabhjainps
force-pushed
the
fix/multipart-download-onerror-cause-ordering
branch
from
July 21, 2026 20:11
6d63b16 to
d4efe6e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Fixes #7174.
When a multipart download (
S3AsyncClientwithmultipartEnabled(true), e.g. viaS3TransferManager.downloadFile) fails, the caller's completion future can complete with a barejava.util.concurrent.CancellationExceptionthat has no cause attached, and the real trigger is never logged.The cause is the ordering in
ParallelMultipartDownloaderSubscriber.onError:Each part future is wired to
resultFuturewithCompletableFutureUtils.forwardExceptionTo(resultFuture, response)insendNextRequest/sendFirstRequest. Cancelling those part futures therefore forwards aCancellationExceptionontoresultFuturebeforeresultFuture.completeExceptionally(t)runs, so the originaltloses the race and is discarded. The method also does not logt, so the trigger is invisible even at DEBUG.The sibling class
ParallelPresignedUrlMultipartDownloaderSubscriber.onErroralready does this correctly — it completesresultFuturebefore cancelling and logs the cause. This change bringsParallelMultipartDownloaderSubscriberin line with it.Modifications
In
ParallelMultipartDownloaderSubscriber.onError:resultFuturewith the originalThrowablebefore cancelling the in-flight part futures, so the real cause wins the race instead of aCancellationException.Testing
ParallelMultipartDownloaderSubscriberTest, which verifies that afteronErrorthe caller-facingresultFuturecompletes with the original throwable (not aCancellationException), that this holds both with and without in-flight part requests, and that in-flight part futures are still cancelled. The test fails against the previous cancel-before-complete ordering and passes with this change.services/s3module with Corretto 21:./mvnw -pl services/s3 -am installsucceeds;-Dtest=ParallelMultipartDownloaderSubscriberTestruns 3/3 green;checkstyle:checkon the module is clean.Types of changes
Checklist
mvn installsucceedsscripts/new-changescript and following the instructions. Commit the new file created by the script in.changes/next-releasewith your changes.License