Skip to content

Fix NPE thrown when creating a default transfer manager #2726

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
merged 3 commits into from
Sep 21, 2021
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
6 changes: 6 additions & 0 deletions .changes/next-release/bugfix-S3TransferManager-1dee8e5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"category": "S3 Transfer Manager",
"contributor": "",
"type": "bugfix",
"description": "Fix the NPE thrown when calling `S3TransferManager.create()`"
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,16 @@
public final class DefaultS3TransferManager implements S3TransferManager {
private final S3CrtAsyncClient s3CrtAsyncClient;

public DefaultS3TransferManager(DefaultBuilder builder) {
public DefaultS3TransferManager(DefaultBuilder tmBuilder) {
S3CrtAsyncClient.S3CrtAsyncClientBuilder clientBuilder = S3CrtAsyncClient.builder();
builder.s3ClientConfiguration.credentialsProvider().ifPresent(clientBuilder::credentialsProvider);
builder.s3ClientConfiguration.maxConcurrency().ifPresent(clientBuilder::maxConcurrency);
builder.s3ClientConfiguration.minimumPartSizeInBytes().ifPresent(clientBuilder::minimumPartSizeInBytes);
builder.s3ClientConfiguration.region().ifPresent(clientBuilder::region);
builder.s3ClientConfiguration.targetThroughputInGbps().ifPresent(clientBuilder::targetThroughputInGbps);
builder.s3ClientConfiguration.asyncConfiguration().ifPresent(clientBuilder::asyncConfiguration);
if (tmBuilder.s3ClientConfiguration != null) {
tmBuilder.s3ClientConfiguration.credentialsProvider().ifPresent(clientBuilder::credentialsProvider);
tmBuilder.s3ClientConfiguration.maxConcurrency().ifPresent(clientBuilder::maxConcurrency);
tmBuilder.s3ClientConfiguration.minimumPartSizeInBytes().ifPresent(clientBuilder::minimumPartSizeInBytes);
tmBuilder.s3ClientConfiguration.region().ifPresent(clientBuilder::region);
tmBuilder.s3ClientConfiguration.targetThroughputInGbps().ifPresent(clientBuilder::targetThroughputInGbps);
tmBuilder.s3ClientConfiguration.asyncConfiguration().ifPresent(clientBuilder::asyncConfiguration);
}

s3CrtAsyncClient = clientBuilder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ public class S3TransferManagerTest {
private S3CrtAsyncClient mockS3Crt;
private S3TransferManager tm;

@Rule
public ExpectedException thrown = ExpectedException.none();

@Before
public void methodSetup() {
mockS3Crt = mock(S3CrtAsyncClient.class);
Expand All @@ -56,6 +53,12 @@ public void methodTeardown() {
tm.close();
}

@Test
public void defaultTransferManager_shouldNotThrowException() {
S3TransferManager transferManager = S3TransferManager.create();
transferManager.close();
}

@Test
public void upload_returnsResponse() {
PutObjectResponse response = PutObjectResponse.builder().build();
Expand Down