Skip to content

Commit 3f4adb3

Browse files
committed
Fix CRT S3 Client builder
- Return the correct type from builder methods - Make max throughput and part size nullable
1 parent 2e741a8 commit 3f4adb3

File tree

3 files changed

+49
-18
lines changed

3 files changed

+49
-18
lines changed

services/s3/src/main/java/software/amazon/awssdk/services/s3/S3CrtAsyncClientBuilder.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@
1515

1616
package software.amazon.awssdk.services.s3;
1717

18+
import java.net.URI;
19+
import java.util.function.Consumer;
1820
import software.amazon.awssdk.annotations.SdkPreviewApi;
1921
import software.amazon.awssdk.annotations.SdkPublicApi;
22+
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
2023
import software.amazon.awssdk.awscore.client.builder.AwsClientBuilder;
24+
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
25+
import software.amazon.awssdk.regions.Region;
2126

2227
/**
2328
* A builder for creating an instance of {@link S3CrtAsyncClient}. This can be created with the static
@@ -26,8 +31,25 @@
2631
@SdkPreviewApi
2732
@SdkPublicApi
2833
public interface S3CrtAsyncClientBuilder extends AwsClientBuilder<S3CrtAsyncClientBuilder, S3CrtAsyncClient> {
34+
@Override
35+
S3CrtAsyncClientBuilder credentialsProvider(AwsCredentialsProvider credentialsProvider);
2936

30-
S3CrtAsyncClientBuilder partSizeBytes(long partSizeBytes);
37+
@Override
38+
S3CrtAsyncClientBuilder region(Region region);
3139

32-
S3CrtAsyncClientBuilder maxThroughputGbps(double maxThroughputGbps);
40+
@Override
41+
S3CrtAsyncClientBuilder overrideConfiguration(ClientOverrideConfiguration overrideConfiguration);
42+
43+
@Override
44+
S3CrtAsyncClientBuilder overrideConfiguration(Consumer<ClientOverrideConfiguration.Builder> overrideConfiguration);
45+
46+
@Override
47+
S3CrtAsyncClientBuilder endpointOverride(URI endpointOverride);
48+
49+
S3CrtAsyncClientBuilder partSizeBytes(Long partSizeBytes);
50+
51+
S3CrtAsyncClientBuilder maxThroughputGbps(Double maxThroughputGbps);
52+
53+
@Override
54+
S3CrtAsyncClient build();
3355
}

services/s3/src/main/java/software/amazon/awssdk/services/s3/internal/s3crt/DefaultS3CrtAsyncClient.java

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import software.amazon.awssdk.annotations.SdkInternalApi;
2626
import software.amazon.awssdk.core.async.AsyncRequestBody;
2727
import software.amazon.awssdk.core.async.AsyncResponseTransformer;
28-
import software.amazon.awssdk.crt.auth.credentials.CredentialsProvider;
2928
import software.amazon.awssdk.services.s3.S3CrtAsyncClient;
3029
import software.amazon.awssdk.services.s3.model.GetObjectRequest;
3130
import software.amazon.awssdk.services.s3.model.GetObjectResponse;
@@ -38,15 +37,25 @@ public final class DefaultS3CrtAsyncClient implements S3CrtAsyncClient {
3837
private final S3NativeClientConfiguration configuration;
3938

4039
public DefaultS3CrtAsyncClient(DefaultS3CrtClientBuilder builder) {
41-
CredentialsProvider credentialsProvider = builder.credentialsProvider() == null ? null :
42-
createCrtCredentialsProvider(builder.credentialsProvider());
43-
44-
this.configuration = S3NativeClientConfiguration.builder()
45-
.credentialsProvider(credentialsProvider)
46-
.signingRegion(builder.region() == null ? null : builder.region().id())
47-
.partSizeBytes(builder.partSizeBytes())
48-
.maxThroughputGbps(builder.maxThroughputGbps())
49-
.build();
40+
S3NativeClientConfiguration.Builder configBuilder = S3NativeClientConfiguration.builder();
41+
42+
if (builder.region() != null) {
43+
configBuilder.signingRegion(builder.region().id());
44+
}
45+
46+
if (builder.credentialsProvider() != null) {
47+
configBuilder.credentialsProvider(createCrtCredentialsProvider(builder.credentialsProvider()));
48+
}
49+
50+
if (builder.maxThroughputGbps() != null) {
51+
configBuilder.maxThroughputGbps(builder.maxThroughputGbps());
52+
}
53+
54+
if (builder.partSizeBytes() != null) {
55+
configBuilder.partSizeBytes(builder.partSizeBytes());
56+
}
57+
58+
configuration = configBuilder.build();
5059

5160
this.s3NativeClient = new S3NativeClient(configuration.signingRegion(),
5261
configuration.clientBootstrap(),

services/s3/src/main/java/software/amazon/awssdk/services/s3/internal/s3crt/DefaultS3CrtClientBuilder.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
public final class DefaultS3CrtClientBuilder implements S3CrtAsyncClientBuilder {
2929
private AwsCredentialsProvider credentialsProvider;
3030
private Region region;
31-
private long partSizeBytes;
32-
private double maxThroughputGbps;
31+
private Long partSizeBytes;
32+
private Double maxThroughputGbps;
3333

3434
public AwsCredentialsProvider credentialsProvider() {
3535
return credentialsProvider;
@@ -39,11 +39,11 @@ public Region region() {
3939
return region;
4040
}
4141

42-
public long partSizeBytes() {
42+
public Long partSizeBytes() {
4343
return partSizeBytes;
4444
}
4545

46-
public double maxThroughputGbps() {
46+
public Double maxThroughputGbps() {
4747
return maxThroughputGbps;
4848
}
4949

@@ -78,13 +78,13 @@ public S3CrtAsyncClientBuilder endpointOverride(URI endpointOverride) {
7878
}
7979

8080
@Override
81-
public S3CrtAsyncClientBuilder partSizeBytes(long partSizeBytes) {
81+
public S3CrtAsyncClientBuilder partSizeBytes(Long partSizeBytes) {
8282
this.partSizeBytes = partSizeBytes;
8383
return this;
8484
}
8585

8686
@Override
87-
public S3CrtAsyncClientBuilder maxThroughputGbps(double maxThroughputGbps) {
87+
public S3CrtAsyncClientBuilder maxThroughputGbps(Double maxThroughputGbps) {
8888
this.maxThroughputGbps = maxThroughputGbps;
8989
return this;
9090
}

0 commit comments

Comments
 (0)