Skip to content

Commit 735fa96

Browse files
committed
pr comments
- Subscriber - logs - typos & javadoc
1 parent 5819ab2 commit 735fa96

File tree

7 files changed

+18
-10
lines changed

7 files changed

+18
-10
lines changed

core/sdk-core/src/main/java/software/amazon/awssdk/core/FileTransformerConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private FileTransformerConfiguration(DefaultBuilder builder) {
4848
this.fileWriteOption = Validate.paramNotNull(builder.fileWriteOption, "fileWriteOption");
4949
this.failureBehavior = Validate.paramNotNull(builder.failureBehavior, "failureBehavior");
5050
this.executorService = builder.executorService;
51-
this.position = builder.position;
51+
this.position = Validate.isNotNegativeOrNull(builder.position, "position");
5252
if (fileWriteOption != FileWriteOption.WRITE_TO_POSITION && position != null) {
5353
throw new IllegalArgumentException(String.format(
5454
"'position' can only be used with 'WRITE_TO_POSITION' file write option, but was used with '%s'",

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ public CompletableFuture<ResponseT> prepare() {
270270
if (isCancelled.get()) {
271271
return individualFuture;
272272
}
273+
log.trace(() -> "calling prepare on the upstream transformer");
273274
CompletableFuture<ResultT> upstreamFuture = upstreamResponseTransformer.prepare();
274275
if (!resultFuture.isDone()) {
275276
CompletableFutureUtils.forwardResultTo(upstreamFuture, resultFuture);
@@ -320,6 +321,7 @@ public void onStream(SdkPublisher<ByteBuffer> publisher) {
320321
@Override
321322
public void exceptionOccurred(Throwable error) {
322323
publisherToUpstream.error(error);
324+
log.trace(() -> "calling exceptionOccurred on the upstream transformer");
323325
upstreamResponseTransformer.exceptionOccurred(error);
324326
}
325327
}

services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/S3TransferManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@
7979
* .build();
8080
* }
8181
*
82-
* <b>Create an S3 Transfer Manager with S3 Multipart Async Client</b>
82+
* <b>Create an S3 Transfer Manager with S3 Multipart Async Client</b>. The S3 Multipart Async Client is an alternative to the CRT
83+
* client that offers the same multipart upload/download feature.
8384
* {@snippet :
8485
* S3AsyncClient s3AsyncClient = s3AsyncClient.builder()
8586
* .multipartEnabled(true)

services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/model/ResumableFileDownload.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.nio.file.Files;
2424
import java.nio.file.Path;
2525
import java.time.Instant;
26+
import java.util.ArrayList;
2627
import java.util.Collections;
2728
import java.util.List;
2829
import java.util.Objects;
@@ -72,7 +73,8 @@ private ResumableFileDownload(DefaultBuilder builder) {
7273
this.s3ObjectLastModified = builder.s3ObjectLastModified;
7374
this.totalSizeInBytes = Validate.isPositiveOrNull(builder.totalSizeInBytes, "totalSizeInBytes");
7475
this.fileLastModified = builder.fileLastModified;
75-
this.completedParts = Validate.getOrDefault(builder.completedParts, Collections::emptyList);
76+
List<Integer> compledPartsList = Validate.getOrDefault(builder.completedParts, Collections::emptyList);
77+
this.completedParts = Collections.unmodifiableList(new ArrayList<>(compledPartsList));
7678
}
7779

7880
@Override
@@ -163,7 +165,7 @@ public OptionalLong totalSizeInBytes() {
163165
* @return part numbers of a multipart download that were completed saved to file.
164166
*/
165167
public List<Integer> completedParts() {
166-
return Collections.unmodifiableList(completedParts);
168+
return completedParts;
167169
}
168170

169171
@Override

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public DownloadObjectHelper(S3AsyncClient s3AsyncClient, long bufferSizeInBytes)
4141
public <T> CompletableFuture<T> downloadObject(
4242
GetObjectRequest getObjectRequest, AsyncResponseTransformer<GetObjectResponse, T> asyncResponseTransformer) {
4343
if (getObjectRequest.range() != null || getObjectRequest.partNumber() != null) {
44-
logSinglePartWarning(getObjectRequest);
44+
logSinglePartMessage(getObjectRequest);
4545
return s3AsyncClient.getObject(getObjectRequest, asyncResponseTransformer);
4646
}
4747
GetObjectRequest requestToPerform = getObjectRequest.toBuilder().checksumMode(ChecksumMode.ENABLED).build();
@@ -62,7 +62,7 @@ private MultipartDownloaderSubscriber subscriber(GetObjectRequest getObjectReque
6262
.orElseGet(() -> new MultipartDownloaderSubscriber(s3AsyncClient, getObjectRequest));
6363
}
6464

65-
private void logSinglePartWarning(GetObjectRequest getObjectRequest) {
65+
private void logSinglePartMessage(GetObjectRequest getObjectRequest) {
6666
String reason = "";
6767
if (getObjectRequest.range() != null) {
6868
reason = " because getObjectRequest range is included in the request."

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ public void response(GetObjectResponse response) {
9595
}
9696

9797
/**
98-
* Return the highest sequentially completed part, 0 means no parts completed
98+
* @return the highest sequentially completed part, 0 means no parts completed. Used for non-sequential operation when parts
99+
* may have been completed in a non-sequential order. For example, if parts [1, 2, 3, 6, 7, 10] were completed, this
100+
* method will return 3.
99101
*
100-
* @return
101102
*/
102103
public int highestSequentialCompletedPart() {
103104
if (completedParts.isEmpty() || completedParts.first() != 1) {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class MultipartDownloaderSubscriber implements Subscriber<AsyncResponseTr
4848

4949
/**
5050
* This value indicates the total number of parts of the object to get. If null, it means we don't know the total amount of
51-
* parts, wither because we haven't received a response from s3 yet to set it, or the object to get is not multipart.
51+
* parts, either because we haven't received a response from s3 yet to set it, or the object to get is not multipart.
5252
*/
5353
private volatile Integer totalParts;
5454

@@ -74,7 +74,7 @@ public class MultipartDownloaderSubscriber implements Subscriber<AsyncResponseTr
7474
/**
7575
* The etag of the object being downloaded.
7676
*/
77-
private String eTag;
77+
private volatile String eTag;
7878

7979
public MultipartDownloaderSubscriber(S3AsyncClient s3, GetObjectRequest getObjectRequest) {
8080
this(s3, getObjectRequest, 0);
@@ -101,6 +101,7 @@ public void onSubscribe(Subscription s) {
101101
public void onNext(AsyncResponseTransformer<GetObjectResponse, GetObjectResponse> asyncResponseTransformer) {
102102
log.trace(() -> String.format("onNext, completed part = %d", completedParts.get()));
103103
if (asyncResponseTransformer == null) {
104+
subscription.cancel();
104105
throw new NullPointerException("onNext must not be called with null asyncResponseTransformer");
105106
}
106107

@@ -111,6 +112,7 @@ public void onNext(AsyncResponseTransformer<GetObjectResponse, GetObjectResponse
111112
logMulitpartComplete(totalParts);
112113
subscription.cancel();
113114
}
115+
return;
114116
}
115117

116118
GetObjectRequest actualRequest = nextRequest(nextPartToGet);

0 commit comments

Comments
 (0)