@@ -51,7 +51,7 @@ public class S3NativeClientConfiguration implements SdkAutoCloseable {
5151 private final ClientBootstrap clientBootstrap ;
5252 private final CrtCredentialsProviderAdapter credentialProviderAdapter ;
5353 private final CredentialsProvider credentialsProvider ;
54- private final long partSizeInBytes ;
54+ private final Long partSizeInBytes ;
5555 private final long thresholdInBytes ;
5656 private final double targetThroughputInGbps ;
5757 private final int maxConcurrency ;
@@ -85,10 +85,8 @@ public S3NativeClientConfiguration(Builder builder) {
8585
8686 this .credentialsProvider = credentialProviderAdapter .crtCredentials ();
8787
88- this .partSizeInBytes = builder .partSizeInBytes == null ? DEFAULT_PART_SIZE_IN_BYTES :
89- builder .partSizeInBytes ;
90- this .thresholdInBytes = builder .thresholdInBytes == null ? this .partSizeInBytes :
91- builder .thresholdInBytes ;
88+ this .partSizeInBytes = builder .partSizeInBytes ;
89+ this .thresholdInBytes = resolveThresholdInBytes (builder );
9290 this .targetThroughputInGbps = builder .targetThroughputInGbps == null ?
9391 DEFAULT_TARGET_THROUGHPUT_IN_GBPS : builder .targetThroughputInGbps ;
9492
@@ -98,8 +96,7 @@ public S3NativeClientConfiguration(Builder builder) {
9896
9997 this .endpointOverride = builder .endpointOverride ;
10098
101- this .readBufferSizeInBytes = builder .readBufferSizeInBytes == null ?
102- partSizeInBytes * 10 : builder .readBufferSizeInBytes ;
99+ this .readBufferSizeInBytes = resolveReadBufferSizeInBytes (builder );
103100
104101 if (builder .httpConfiguration != null ) {
105102 this .proxyOptions = resolveProxy (builder .httpConfiguration .proxyConfiguration (), tlsContext ).orElse (null );
@@ -115,6 +112,21 @@ public S3NativeClientConfiguration(Builder builder) {
115112 this .useEnvironmentVariableProxyOptionsValues = resolveUseEnvironmentVariableValues (builder );
116113 }
117114
115+ private Long resolveReadBufferSizeInBytes (Builder builder ) {
116+ if (builder .readBufferSizeInBytes != null ) {
117+ return builder .readBufferSizeInBytes ;
118+ }
119+ long partSize = this .partSizeInBytes == null ? DEFAULT_PART_SIZE_IN_BYTES : this .partSizeInBytes ;
120+ return partSize * 10 ;
121+ }
122+
123+ private long resolveThresholdInBytes (Builder builder ) {
124+ if (builder .thresholdInBytes != null ) {
125+ return builder .thresholdInBytes ;
126+ }
127+ return this .partSizeInBytes == null ? DEFAULT_PART_SIZE_IN_BYTES : this .partSizeInBytes ;
128+ }
129+
118130 private static Boolean resolveUseEnvironmentVariableValues (Builder builder ) {
119131 if (builder != null && builder .httpConfiguration != null && builder .httpConfiguration .proxyConfiguration () != null ) {
120132 return builder .httpConfiguration .proxyConfiguration ().isUseEnvironmentVariableValues ();
@@ -159,7 +171,7 @@ public TlsContext tlsContext() {
159171 return tlsContext ;
160172 }
161173
162- public long partSizeBytes () {
174+ public Long partSizeBytes () {
163175 return partSizeInBytes ;
164176 }
165177
0 commit comments