Skip to content

Commit aa302be

Browse files
Address PR comments: use Long type, inline variables, allow empty files
1 parent 60fe487 commit aa302be

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class PresignedUrlMultipartDownloaderSubscriber
5353

5454
private final S3AsyncClient s3AsyncClient;
5555
private final PresignedUrlDownloadRequest presignedUrlDownloadRequest;
56-
private final long configuredPartSizeInBytes;
56+
private final Long configuredPartSizeInBytes;
5757
private final CompletableFuture<Void> future;
5858
private final Object lock = new Object();
5959
private final AtomicInteger completedParts;
@@ -139,11 +139,9 @@ private void requestMoreIfNeeded(GetObjectResponse response) {
139139
if (totalContentLength == null && response.contentRange() != null) {
140140
try {
141141
validateResponse(response);
142-
long totalSize = parseContentRangeForTotalSize(response.contentRange());
143-
int calculatedTotalParts = calculateTotalParts(totalSize, configuredPartSizeInBytes);
144-
this.totalContentLength = totalSize;
145-
this.totalParts = calculatedTotalParts;
146-
log.debug(() -> String.format("Total content length: %d, Total parts: %d", totalSize, calculatedTotalParts));
142+
this.totalContentLength = parseContentRangeForTotalSize(response.contentRange());
143+
this.totalParts = calculateTotalParts(totalContentLength, configuredPartSizeInBytes);
144+
log.debug(() -> String.format("Total content length: %d, Total parts: %d", totalContentLength, totalParts));
147145
} catch (Exception e) {
148146
log.debug(() -> "Failed to parse content range", e);
149147
handleError(e);
@@ -167,7 +165,7 @@ private void validateResponse(GetObjectResponse response) {
167165
throw new IllegalStateException("No Content-Range header in response");
168166
}
169167
Long contentLength = response.contentLength();
170-
if (contentLength == null || contentLength <= 0) {
168+
if (contentLength == null || contentLength < 0) {
171169
throw new IllegalStateException("Invalid or missing Content-Length in response");
172170
}
173171
}

services/s3/src/test/java/software/amazon/awssdk/services/s3/internal/multipart/PresignedUrlMultipartDownloadTestUtil.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,4 @@ public void verifyNoRequestMadeForRange(long startByte, long endByte) {
147147
verify(0, getRequestedFor(urlEqualTo(PRESIGNED_URL_PATH))
148148
.withHeader("Range", new EqualToPattern(rangeHeader)));
149149
}
150-
151-
// Additional utility methods for error condition testing can be added here as needed
152150
}

0 commit comments

Comments
 (0)