Skip to content

Commit 37ec203

Browse files
committed
Added Null checks and test cases
1 parent 602fd9a commit 37ec203

File tree

4 files changed

+46
-6
lines changed

4 files changed

+46
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ default S3CrtAsyncClientBuilder httpConfiguration(Consumer<S3CrtHttpConfiguratio
195195
* @see #retryConfiguration(S3CrtRetryConfiguration)
196196
*/
197197
default S3CrtAsyncClientBuilder retryConfiguration(Consumer<S3CrtRetryConfiguration.Builder> retryConfigurationBuilder) {
198-
Validate.paramNotNull(retryConfigurationBuilder, "configurationBuilder");
198+
Validate.paramNotNull(retryConfigurationBuilder, "retryConfigurationBuilder");
199199
return retryConfiguration(S3CrtRetryConfiguration.builder()
200200
.applyMutation(retryConfigurationBuilder)
201201
.build());

services/s3/src/main/java/software/amazon/awssdk/services/s3/crt/S3CrtRetryConfiguration.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import software.amazon.awssdk.annotations.Immutable;
2020
import software.amazon.awssdk.annotations.SdkPublicApi;
2121
import software.amazon.awssdk.annotations.ThreadSafe;
22+
import software.amazon.awssdk.core.retry.RetryPolicy;
2223
import software.amazon.awssdk.services.s3.S3CrtAsyncClientBuilder;
2324
import software.amazon.awssdk.utils.Validate;
2425
import software.amazon.awssdk.utils.builder.CopyableBuilder;
@@ -37,7 +38,7 @@ public final class S3CrtRetryConfiguration implements ToCopyableBuilder<S3CrtRet
3738
private final Integer numRetries;
3839

3940
private S3CrtRetryConfiguration(DefaultBuilder builder) {
40-
Validate.isPositiveOrNull(builder.numRetries, "numRetries");
41+
Validate.notNull(builder.numRetries, "numRetries");
4142
this.numRetries = builder.numRetries;
4243
}
4344

@@ -49,7 +50,7 @@ public static Builder builder() {
4950
}
5051

5152
/**
52-
* Return the amount of time to wait when initially establishing a connection before giving up and timing out.
53+
* Retrieve the {@link S3CrtRetryConfiguration.Builder#numRetries(Integer)} configured on the builder.
5354
*/
5455
public Integer numRetries() {
5556
return numRetries;

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,7 @@ private static S3CrtAsyncHttpClient.Builder initializeS3CrtAsyncHttpClient(Defau
105105
.targetThroughputInGbps(builder.targetThroughputInGbps)
106106
.partSizeInBytes(builder.minimalPartSizeInBytes)
107107
.maxConcurrency(builder.maxConcurrency)
108-
.signingRegion(builder.region == null ? null
109-
:
110-
builder.region.id())
108+
.signingRegion(builder.region == null ? null : builder.region.id())
111109
.endpointOverride(builder.endpointOverride)
112110
.credentialsProvider(builder.credentialsProvider)
113111
.readBufferSizeInBytes(builder.readBufferSizeInBytes)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
package software.amazon.awssdk.services.s3.crt;
17+
18+
import nl.jqno.equalsverifier.EqualsVerifier;
19+
import org.junit.jupiter.api.Test;
20+
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
21+
import static org.assertj.core.api.Assertions.assertThatNullPointerException;
22+
23+
24+
public class S3CrtRetryConfigurationTest {
25+
26+
@Test
27+
void equalsHashcode() {
28+
EqualsVerifier.forClass(S3CrtRetryConfiguration.class)
29+
.withRedefinedSuperclass()
30+
.verify();
31+
}
32+
33+
@Test
34+
void retryConfigurationWithNoMaxRetriesDefined(){
35+
assertThatNullPointerException().isThrownBy(() ->S3CrtRetryConfiguration.builder().build())
36+
.withMessage("numRetries");
37+
}
38+
39+
40+
41+
}

0 commit comments

Comments
 (0)