Skip to content

Fixed an issue where sdkRepsonse is not present in the ProgressSnapsh… #3585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ void upload_file_SentCorrectly() throws IOException {
.isEqualTo(ChecksumUtils.computeCheckSum(obj));
assertThat(obj.response().responseMetadata().requestId()).isNotNull();
assertThat(obj.response().metadata()).containsEntry("foobar", "FOO BAR");
assertThat(fileUpload.progress().snapshot().sdkResponse()).isPresent();
}

@Test
Expand All @@ -105,5 +106,6 @@ void upload_asyncRequestBody_SentCorrectly() throws IOException {
assertThat(ChecksumUtils.computeCheckSum(content.getBytes(StandardCharsets.UTF_8)))
.isEqualTo(ChecksumUtils.computeCheckSum(obj));
assertThat(obj.response().responseMetadata().requestId()).isNotNull();
assertThat(upload.progress().snapshot().sdkResponse()).isPresent();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ public void registerCompletion(CompletableFuture<? extends CompletedObjectTransf
private void transferComplete(CompletedObjectTransfer r) {
listenerInvoker.transferComplete(context.copy(b -> {
TransferProgressSnapshot snapshot = progress.snapshot();
if (!snapshot.sdkResponse().isPresent()) {
snapshot = progress.updateAndGet(p -> p.sdkResponse(r.response()));
}

b.progressSnapshot(snapshot);
b.completedTransfer(r);
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ private CompletedCopy(DefaultBuilder builder) {
this.response = Validate.paramNotNull(builder.response, "response");
}

@Override
public CopyObjectResponse response() {
return response;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ private CompletedFileDownload(DefaultBuilder builder) {
this.response = Validate.paramNotNull(builder.response, "response");
}

@Override
public GetObjectResponse response() {
return response;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ private CompletedFileUpload(DefaultBuilder builder) {
this.response = Validate.paramNotNull(builder.response, "response");
}

@Override
public PutObjectResponse response() {
return response;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import software.amazon.awssdk.annotations.SdkPreviewApi;
import software.amazon.awssdk.annotations.SdkPublicApi;
import software.amazon.awssdk.core.SdkResponse;

/**
* A completed single object transfer.
Expand All @@ -29,4 +30,11 @@
@SdkPublicApi
@SdkPreviewApi
public interface CompletedObjectTransfer extends CompletedTransfer {

/**
* Return the {@link SdkResponse} associated with this transfer
*/
default SdkResponse response() {
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ private CompletedUpload(DefaultBuilder builder) {
this.response = Validate.paramNotNull(builder.response, "response");
}

@Override
public PutObjectResponse response() {
return response;
}
Expand Down