Skip to content

Commit

Permalink
[SDK-615] fixed LargeFileUploader to pull root cause exception when c…
Browse files Browse the repository at this point in the history
…hecking for CancellationException from futures, as some executors may wrap the exception multiple times
  • Loading branch information
Stu Arnett committed Aug 22, 2022
1 parent 05a2434 commit e171337
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/com/emc/object/s3/LargeFileUploader.java
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,11 @@ public void doMultipartUpload() {
try {
resumeContext.getUploadedParts().put(future.get().getPartNumber(), future.get());
} catch (ExecutionException e) { // unfortunately, we can't just catch CancellationException here
// get the root cause
Throwable t = e;
while (t.getCause() != null && t.getCause() != t) t = t.getCause();
// CancellationException is only thrown when we are terminated early - cancelled tasks will just be ignored
if (e.getCause() == null || !(e.getCause() instanceof CancellationException)) throw e;
if (!(t instanceof CancellationException)) throw e;
}
}

Expand Down

0 comments on commit e171337

Please sign in to comment.