Skip to content

Commit c1acdd8

Browse files
committed
feedback addressed
1 parent fc956ac commit c1acdd8

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

.changes/next-release/bugfix-AWSSDKforJavav2-17f90b1.json

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"type": "bugfix",
3+
"category": "Amazon S3",
4+
"contributor": "",
5+
"description": "Added additional validations for multipart download operations in the Java multipart S3 client"
6+
}

services/s3/src/main/java/software/amazon/awssdk/services/s3/internal/multipart/MultipartDownloaderSubscriber.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,13 @@ public void onNext(AsyncResponseTransformer<GetObjectResponse, GetObjectResponse
114114
throw new NullPointerException("onNext must not be called with null asyncResponseTransformer");
115115
}
116116

117-
int nextPartToGet = completedParts.get() + 1;
117+
int currentPart = completedParts.get();
118+
int nextPartToGet = currentPart + 1;
118119

119120
synchronized (lock) {
120121
if (totalParts != null && nextPartToGet > totalParts) {
121-
validatePartsCount(completedParts.get());
122122
log.debug(() -> String.format("Completing multipart download after a total of %d parts downloaded.", totalParts));
123+
validatePartsCount(currentPart);
123124
subscription.cancel();
124125
return;
125126
}
@@ -168,7 +169,7 @@ private void requestMoreIfNeeded(GetObjectResponse response) {
168169
if (totalParts != null && totalParts > 1 && totalComplete < totalParts) {
169170
subscription.request(1);
170171
} else {
171-
validatePartsCount(completedParts.get());
172+
validatePartsCount(totalComplete);
172173
log.debug(() -> String.format("Completing multipart download after a total of %d parts downloaded.", totalParts));
173174
subscription.cancel();
174175
}
@@ -204,9 +205,8 @@ private GetObjectRequest nextRequest(int nextPartToGet) {
204205

205206
private void validatePartsCount(int currentGetCount) {
206207
if (totalParts != null && currentGetCount != totalParts) {
207-
String errorMessage = "PartsCount validation failed. Expected " + totalParts + ", downloaded"
208-
+ " " + currentGetCount + " parts.";
209-
log.error(() -> errorMessage);
208+
String errorMessage = String.format("PartsCount validation failed. Expected %d, downloaded %d parts.", totalParts,
209+
currentGetCount);
210210
subscription.cancel();
211211
SdkClientException exception = SdkClientException.create(errorMessage);
212212
onError(exception);

test/architecture-tests/src/test/java/software/amazon/awssdk/archtests/CodingConventionWithSuppressionTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import software.amazon.awssdk.core.sync.ResponseTransformer;
3737
import software.amazon.awssdk.metrics.publishers.emf.EmfMetricLoggingPublisher;
3838
import software.amazon.awssdk.metrics.publishers.emf.internal.MetricEmfConverter;
39-
import software.amazon.awssdk.services.s3.internal.multipart.MultipartDownloaderSubscriber;
4039
import software.amazon.awssdk.utils.Logger;
4140

4241
/**
@@ -58,7 +57,6 @@ public class CodingConventionWithSuppressionTest {
5857
private static final Set<Pattern> ALLOWED_ERROR_LOG_SUPPRESSION = new HashSet<>(
5958
Arrays.asList(
6059
ArchUtils.classNameToPattern(EmfMetricLoggingPublisher.class),
61-
ArchUtils.classNameToPattern(MultipartDownloaderSubscriber.class),
6260
ArchUtils.classWithInnerClassesToPattern(ResponseTransformer.class)));
6361

6462
@Test

0 commit comments

Comments
 (0)