From e1713371bf65a44140b00e3d8b89aef32f75a9c3 Mon Sep 17 00:00:00 2001 From: Stu Arnett Date: Mon, 22 Aug 2022 00:32:28 -0500 Subject: [PATCH] [SDK-615] fixed LargeFileUploader to pull root cause exception when checking for CancellationException from futures, as some executors may wrap the exception multiple times --- src/main/java/com/emc/object/s3/LargeFileUploader.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/emc/object/s3/LargeFileUploader.java b/src/main/java/com/emc/object/s3/LargeFileUploader.java index 0613b31e..a5349806 100755 --- a/src/main/java/com/emc/object/s3/LargeFileUploader.java +++ b/src/main/java/com/emc/object/s3/LargeFileUploader.java @@ -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; } }