Skip to content

Commit a69bad6

Browse files
committed
chore: add BidiUploadStreamingStream
This class is a higher level abstraction over bidi stream, retries and state tracking. Taking care of most concerns once data is in a ChunkSegment.
1 parent 437797f commit a69bad6

File tree

9 files changed

+2278
-23
lines changed

9 files changed

+2278
-23
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,17 @@ abstract class BidiUploadState {
7474
// seal this class to extension
7575
private BidiUploadState() {}
7676

77+
@VisibleForTesting
78+
BidiUploadState(String testName) {
79+
// some runtime enforcement that this constructor is only called from a test
80+
// if we had java9+ we could seal this all the way without this hack
81+
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
82+
boolean isJunitTest =
83+
Arrays.stream(stackTrace).anyMatch(ste -> ste.getClassName().startsWith("org.junit"));
84+
85+
checkState(isJunitTest, "not a junit test", testName);
86+
}
87+
7788
protected final StorageException err(
7889
UploadFailureScenario scenario, BidiWriteObjectResponse response) {
7990
BidiWriteObjectRequest t = peekLast();

0 commit comments

Comments
 (0)