Skip to content

Commit 5c9cecf

Browse files
authored
fix: update grpc bidi resumable uploads to validate ack'd object size (#2570)
* fix: update grpc bidi resumable uploads to validate ack'd object size Follow up to #2527 Part 1, add tests and simulation server * fix: update grpc bidi resumable uploads to validate ack'd object size Follow up to #2527 Cleanup unused inner-class * fix: update grpc bidi resumable uploads to validate ack'd object size Follow up to #2527 Move request trimming inline rather than at the end * fix: update grpc bidi resumable uploads to validate ack'd object size Follow up to #2527 Update GapicBidiUnbufferedWritableByteChannel to correctly handle failure scenarios {1, 2, 3, 4, 4_1, 4_2, 5, 7} Refactor ResumableSessionFailureScenario to accept Message and List rather than WriteObjectResponse and List<WriteObjectRequest>. The shape of BidiWriteObjectRequest/WriteObjectRequest and BidiWriteObjectResponse/WriteObjectResponse are largely the same (bidi has two extra fields) so rather than overloading toStorageException yet again, this time there is a single method for grpc messages that internally can branch when formatting the request. In this case, we're quite safe taking this relaxed typing because it is an internal API that is only called from a grpc context where protos will be used. * fix: update grpc bidi resumable uploads to validate ack'd object size Follow up to #2527 Update GapicBidiUnbufferedWritableByteChannel to correctly handle partial consumption of content Tests passing now. Separate tracking of client detected errors and stream errors. When await is invoked, if a client detected error is present AND a stream error is present, the client detected error will take precedence. If a stream error happens and the client detected error has not yet been observed, the stream error will be added as a suppressed exception to the client detected error. * chore: fix failing tests
1 parent 55a6d15 commit 5c9cecf

File tree

8 files changed

+1340
-160
lines changed

8 files changed

+1340
-160
lines changed

google-cloud-storage/src/main/java/com/google/cloud/storage/BidiResumableWrite.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public StartResumableWriteResponse getRes() {
5252

5353
@Override
5454
public BidiWriteObjectRequest.Builder newBuilder() {
55-
return writeRequest.toBuilder();
55+
return writeRequest.toBuilder().clearWriteObjectSpec();
5656
}
5757

5858
@Override

google-cloud-storage/src/main/java/com/google/cloud/storage/BidiWriteCtx.java

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package com.google.cloud.storage;
1818

19-
import static com.google.cloud.storage.StorageV2ProtoUtils.fmtProto;
20-
2119
import com.google.cloud.storage.BidiWriteCtx.BidiWriteObjectRequestBuilderFactory;
2220
import com.google.cloud.storage.Crc32cValue.Crc32cLengthKnown;
2321
import com.google.storage.v2.BidiWriteObjectRequest;
@@ -84,36 +82,5 @@ interface BidiWriteObjectRequestBuilderFactory {
8482

8583
@Nullable
8684
String bucketName();
87-
88-
static BidiSimpleWriteObjectRequestBuilderFactory simple(BidiWriteObjectRequest req) {
89-
return new BidiSimpleWriteObjectRequestBuilderFactory(req);
90-
}
91-
}
92-
93-
static final class BidiSimpleWriteObjectRequestBuilderFactory
94-
implements BidiWriteObjectRequestBuilderFactory {
95-
private final BidiWriteObjectRequest req;
96-
97-
private BidiSimpleWriteObjectRequestBuilderFactory(BidiWriteObjectRequest req) {
98-
this.req = req;
99-
}
100-
101-
@Override
102-
public BidiWriteObjectRequest.Builder newBuilder() {
103-
return req.toBuilder();
104-
}
105-
106-
@Override
107-
public @Nullable String bucketName() {
108-
if (req.hasWriteObjectSpec() && req.getWriteObjectSpec().hasResource()) {
109-
return req.getWriteObjectSpec().getResource().getBucket();
110-
}
111-
return null;
112-
}
113-
114-
@Override
115-
public String toString() {
116-
return "SimpleBidiWriteObjectRequestBuilderFactory{" + "req=" + fmtProto(req) + '}';
117-
}
11885
}
11986
}

0 commit comments

Comments
 (0)