Skip to content

Commit a688479

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

File tree

4 files changed

+45
-6
lines changed

4 files changed

+45
-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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public final class S3CrtRetryConfiguration implements ToCopyableBuilder<S3CrtRet
3737
private final Integer numRetries;
3838

3939
private S3CrtRetryConfiguration(DefaultBuilder builder) {
40-
Validate.isPositiveOrNull(builder.numRetries, "numRetries");
40+
Validate.notNull(builder.numRetries, "numRetries");
4141
this.numRetries = builder.numRetries;
4242
}
4343

@@ -49,7 +49,7 @@ public static Builder builder() {
4949
}
5050

5151
/**
52-
* Return the amount of time to wait when initially establishing a connection before giving up and timing out.
52+
* Retrieve the {@link S3CrtRetryConfiguration.Builder#numRetries(Integer)} configured on the builder.
5353
*/
5454
public Integer numRetries() {
5555
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)