Skip to content

Commit 33c2234

Browse files
committed
Add check for total parts
1 parent 0fa8725 commit 33c2234

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/async/ByteArraySplittingTransformer.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,15 @@ private void handleSubscriptionCancel() {
183183

184184
upstreamResponseTransformer.onResponse(responseT.get());
185185

186-
for (int i = 1; i <= buffers.size(); ++i) {
186+
int totalPartCount = nextPartNumber.get() - 1;
187+
if (buffers.size() != totalPartCount) {
188+
resultFuture.completeExceptionally(
189+
SdkClientException.create(String.format("Number of parts in buffer [%d] does not match total part count"
190+
+ " [%d], some parts did not complete successfully.",
191+
buffers.size(), totalPartCount)));
192+
return;
193+
}
194+
for (int i = 1; i <= totalPartCount; ++i) {
187195
publisherToUpstream.send(buffers.get(i)).exceptionally(ex -> {
188196
resultFuture.completeExceptionally(SdkClientException.create("unexpected error occurred", ex));
189197
return null;

0 commit comments

Comments
 (0)