FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: update grpc resumable upload error categorization to be more tolerant by BenWhitehead · Pull Request #2644 · googleapis/java-storage · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .java  (3) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.google.cloud.storage;

import static com.google.cloud.storage.GrpcUtils.contextWithBucketName;
import static com.google.cloud.storage.Utils.nullSafeList;

import com.google.api.core.SettableApiFuture;
import com.google.api.gax.grpc.GrpcCallContext;
Expand All @@ -26,7 +27,6 @@
import com.google.cloud.storage.ChunkSegmenter.ChunkSegment;
import com.google.cloud.storage.Crc32cValue.Crc32cLengthKnown;
import com.google.cloud.storage.UnbufferedWritableByteChannelSession.UnbufferedWritableByteChannel;
import com.google.common.collect.ImmutableList;
import com.google.protobuf.ByteString;
import com.google.storage.v2.ChecksummedData;
import com.google.storage.v2.ObjectChecksums;
Expand Down Expand Up @@ -230,7 +230,7 @@ public void onError(Throwable t) {
tmp.getCode(),
tmp.getMessage(),
tmp.getReason(),
ImmutableList.of(lastWrittenRequest),
nullSafeList(lastWrittenRequest),
null,
context,
t);
Expand All @@ -251,7 +251,7 @@ public void onCompleted() {
0,
"onComplete without preceding onNext, unable to determine success.",
"invalid",
ImmutableList.of(lastWrittenRequest),
nullSafeList(lastWrittenRequest),
null,
context,
null));
Expand All @@ -263,26 +263,26 @@ public void onCompleted() {
} else if (finalSize < totalSentBytes) {
clientDetectedError(
ResumableSessionFailureScenario.SCENARIO_4_1.toStorageException(
ImmutableList.of(lastWrittenRequest), last, context, null));
nullSafeList(lastWrittenRequest), last, context, null));
} else {
clientDetectedError(
ResumableSessionFailureScenario.SCENARIO_4_2.toStorageException(
ImmutableList.of(lastWrittenRequest), last, context, null));
nullSafeList(lastWrittenRequest), last, context, null));
}
} else if (!finalizing || last.hasPersistedSize()) { // unexpected incremental response
clientDetectedError(
ResumableSessionFailureScenario.toStorageException(
0,
"Unexpected incremental response for finalizing request.",
"invalid",
ImmutableList.of(lastWrittenRequest),
nullSafeList(lastWrittenRequest),
last,
context,
null));
} else {
clientDetectedError(
ResumableSessionFailureScenario.SCENARIO_0.toStorageException(
ImmutableList.of(lastWrittenRequest), last, context, null));
nullSafeList(lastWrittenRequest), last, context, null));
}
}

Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ static StorageException toStorageException(
Map<String, List<String>> extraHeaders = context.getExtraHeaders();
recordHeadersTo(extraHeaders, PREFIX_O, sb);
int length = reqs.size();
if (length == 0) {
sb.append("\n").append(PREFIX_O).append("[]");
}
for (int i = 0; i < length; i++) {
if (i == 0) {
sb.append("\n").append(PREFIX_O).append("[");
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.google.cloud.storage.Conversions.Codec;
import com.google.cloud.storage.UnifiedOpts.NamedField;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.MapDifference;
import com.google.common.collect.Maps;
import com.google.common.io.BaseEncoding;
Expand Down Expand Up @@ -310,4 +311,12 @@ private static String crc32cEncode(int from) {
static GrpcCallContext merge(@NonNull GrpcCallContext l, @NonNull GrpcCallContext r) {
return (GrpcCallContext) l.merge(r);
}

static <T> ImmutableList<T> nullSafeList(@Nullable T t) {
if (t == null) {
return ImmutableList.of();
} else {
return ImmutableList.of(t);
}
}
}

Back | FazBrowse Home | New Git URL