Skip to content

Commit b10c73e

Browse files
authored
PR 5164 remaining comments (#5403)
* PR Comments - Improved documentation - Added warning for null future - Remove superfluous isCancel() call - lazy logging
1 parent 9e58e88 commit b10c73e

File tree

7 files changed

+29
-18
lines changed

7 files changed

+29
-18
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,15 @@ default SplitResult<ResponseT, ResultT> split(SplittingTransformerConfiguration
142142
.build();
143143
}
144144

145+
/**
146+
* Creates an {@link SplitResult} which contains an {@link SplittingTransformer} that splits the
147+
* {@link AsyncResponseTransformer} into multiple ones, publishing them as a {@link SdkPublisher}.
148+
*
149+
* @param splitConfig configuration for the split transformer
150+
* @return SplitAsyncResponseTransformer instance.
151+
* @see SplittingTransformer
152+
* @see SplitResult
153+
*/
145154
default SplitResult<ResponseT, ResultT> split(Consumer<SplittingTransformerConfiguration.Builder> splitConfig) {
146155
SplittingTransformerConfiguration conf = SplittingTransformerConfiguration.builder()
147156
.applyMutation(splitConfig)

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ public void exceptionOccurred(Throwable throwable) {
163163
}
164164
if (cf != null) {
165165
cf.completeExceptionally(throwable);
166+
} else {
167+
log.warn(() -> "An exception occurred before the call to prepare() was able to instantiate the CompletableFuture."
168+
+ "The future cannot be completed exceptionally because it is null");
166169
}
167170
}
168171

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,6 @@ public void request(long n) {
155155
downstreamSubscriber.onError(new IllegalArgumentException("Amount requested must be positive"));
156156
return;
157157
}
158-
if (isCancelled.get()) {
159-
return;
160-
}
161158
long newDemand = outstandingDemand.updateAndGet(current -> {
162159
if (Long.MAX_VALUE - current < n) {
163160
return Long.MAX_VALUE;

core/sdk-core/src/test/java/software/amazon/awssdk/core/internal/async/FileAsyncResponseTransformerTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
import software.amazon.awssdk.core.FileTransformerConfiguration.FileWriteOption;
5353
import software.amazon.awssdk.core.FileTransformerConfiguration.FailureBehavior;
5454
import software.amazon.awssdk.core.async.SdkPublisher;
55-
import software.amazon.awssdk.core.util.FileUtils;
5655

5756
/**
5857
* Tests for {@link FileAsyncResponseTransformer}.
@@ -335,9 +334,9 @@ private static void stubException(String newContent, FileAsyncResponseTransforme
335334
transformer.onStream(SdkPublisher.adapt(Flowable.just(content, content)));
336335
transformer.exceptionOccurred(runtimeException);
337336

338-
assertThatThrownBy(() -> future.get(10, TimeUnit.SECONDS))
339-
.hasRootCause(runtimeException);
340-
assertThat(future.isCompletedExceptionally()).isTrue();
337+
assertThat(future).failsWithin(1, TimeUnit.SECONDS)
338+
.withThrowableOfType(ExecutionException.class)
339+
.withCause(runtimeException);
341340
}
342341

343342
private static SdkPublisher<ByteBuffer> testPublisher(String content) {

services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/internal/utils/ResumableRequestConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private ResumableRequestConverter() {
9292
return Pair.of(originalDownloadRequest, responseTransformer);
9393
}
9494

95-
// ranged GET for the remaining bytes (as a single request, no multipart)
95+
// ranged GET for the remaining bytes.
9696
newDownloadFileRequest = resumedDownloadFileRequest(resumableFileDownload,
9797
originalDownloadRequest,
9898
getObjectRequest,

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,16 @@ private MultipartDownloaderSubscriber subscriber(GetObjectRequest getObjectReque
6363
}
6464

6565
private void logSinglePartMessage(GetObjectRequest getObjectRequest) {
66-
String reason = "";
67-
if (getObjectRequest.range() != null) {
68-
reason = " because getObjectRequest range is included in the request."
69-
+ " range = " + getObjectRequest.range();
70-
} else if (getObjectRequest.partNumber() != null) {
71-
reason = " because getObjectRequest part number is included in the request."
72-
+ " part number = " + getObjectRequest.partNumber();
73-
}
74-
String finalReason = reason;
75-
log.debug(() -> "Using single part download" + finalReason);
66+
log.debug(() -> {
67+
String reason = "";
68+
if (getObjectRequest.range() != null) {
69+
reason = " because getObjectRequest range is included in the request."
70+
+ " range = " + getObjectRequest.range();
71+
} else if (getObjectRequest.partNumber() != null) {
72+
reason = " because getObjectRequest part number is included in the request."
73+
+ " part number = " + getObjectRequest.partNumber();
74+
}
75+
return "Using single part download" + reason;
76+
});
7677
}
7778
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ public int highestSequentialCompletedPart() {
108108
return 1;
109109
}
110110

111+
// for sequential operation, make sure we don't skip any non-completed part by returning the
112+
// highest sequentially completed part
111113
int previous = completedParts.first();
112114
for (Integer i : completedParts) {
113115
if (i - previous > 1) {

0 commit comments

Comments
 (0)