diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/ParallelCompositeUploadException.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/ParallelCompositeUploadException.java index b03348e569..2cc791e16e 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/ParallelCompositeUploadException.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/ParallelCompositeUploadException.java @@ -21,28 +21,42 @@ import com.google.api.gax.rpc.ApiException; import com.google.api.gax.rpc.ErrorDetails; import com.google.api.gax.rpc.StatusCode; -import com.google.common.collect.ImmutableList; import io.grpc.Status.Code; +import java.util.List; -final class ParallelCompositeUploadException extends ApiException { +/** + * An exception which provides access to created objects during a Parallel Composite Upload that did + * not finish successfully. + * + *
This exception can occur when calling any method on the {@link + * java.nio.channels.WritableByteChannel} returned from {@link BlobWriteSession#open()}, in which + * case it will be the cause of a {@link StorageException}. + * + *
Similarly, this exception will be the cause of a {@link
+ * java.util.concurrent.CancellationException} thrown by the {@link BlobWriteSession#getResult()}.
+ */
+public final class ParallelCompositeUploadException extends ApiException {
- private final ApiFuture> createdObjects;
private ParallelCompositeUploadException(
Throwable cause,
StatusCode statusCode,
ErrorDetails errorDetails,
- ApiFuture
> createdObjects) {
super(cause, statusCode, false, errorDetails);
this.createdObjects = createdObjects;
}
- public ApiFuture
> getCreatedObjects() {
return createdObjects;
}
- static ParallelCompositeUploadException of(
- Throwable t, ApiFuture
> createdObjects) {
StatusCode statusCode;
ErrorDetails errorDetails;
diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/ParallelCompositeUploadWritableByteChannel.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/ParallelCompositeUploadWritableByteChannel.java
index ed33f97553..9ff1ebdb58 100644
--- a/google-cloud-storage/src/main/java/com/google/cloud/storage/ParallelCompositeUploadWritableByteChannel.java
+++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/ParallelCompositeUploadWritableByteChannel.java
@@ -431,7 +431,7 @@ private BlobInfo definePart(BlobInfo ultimateObject, PartRange partRange, long o
}
private
> pendingAndSuccessfulBlobIds =
getPendingAndSuccessfulBlobIds(exec, pendingParts, successfulParts);
return ApiFutures.transformAsync(
pendingAndSuccessfulBlobIds,
@@ -558,21 +558,21 @@ static ParallelCompositeUploadException buildParallelCompositeUploadException(
Executor exec,
List
> fCreatedObjects =
getPendingAndSuccessfulBlobIds(exec, pendingParts, successfulParts);
return ParallelCompositeUploadException.of(cause, fCreatedObjects);
}
@NonNull
- private static ApiFuture
> getPendingAndSuccessfulBlobIds(
Executor exec, List
> successfulList = ApiFutures.successfulAsList(pendingParts);
// suppress any failure that might happen when waiting for any pending futures to resolve
ApiFuture
> catching =
ApiFutures.catching(successfulList, Throwable.class, t2 -> ImmutableList.of(), exec);
- ApiFuture
> fCreatedObjects =
ApiFutures.transform(
catching,
l ->