Skip to content

Commit b337725

Browse files
committed
Update to use better error message when URI scheme is null in endpointOverride
1 parent 7881691 commit b337725

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

core/sdk-core/src/main/java/software/amazon/awssdk/core/client/builder/SdkDefaultClientBuilder.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ private Executor resolveAsyncFutureCompletionExecutor(SdkClientConfiguration con
284284
}
285285

286286
/**
287-
* Finalize which scheduled executor service will be used for retries in the created client.
287+
* Finalize the internal SDK scheduled executor service that is used for scheduling tasks such
288+
* as async retry attempts and timeout task.
288289
*/
289290
private ScheduledExecutorService resolveScheduledExecutorService() {
290291
return Executors.newScheduledThreadPool(5, new ThreadFactoryBuilder()
@@ -301,6 +302,8 @@ private List<ExecutionInterceptor> resolveExecutionInterceptors(SdkClientConfigu
301302

302303
@Override
303304
public final B endpointOverride(URI endpointOverride) {
305+
Validate.paramNotNull(endpointOverride, "endpointOverride");
306+
Validate.paramNotNull(endpointOverride.getScheme(), "The URI scheme of endpointOverride");
304307
clientConfiguration.option(SdkClientOption.ENDPOINT, endpointOverride);
305308
return thisBuilder();
306309
}

core/sdk-core/src/test/java/software/amazon/awssdk/core/client/builder/DefaultClientBuilderTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package software.amazon.awssdk.core.client.builder;
1717

1818
import static org.assertj.core.api.Assertions.assertThat;
19+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
1920
import static org.mockito.Matchers.any;
2021
import static org.mockito.Mockito.mock;
2122
import static org.mockito.Mockito.never;
@@ -90,6 +91,13 @@ public void buildWithEndpointShouldHaveCorrectEndpointAndSigningRegion() {
9091
assertThat(client.clientConfiguration.option(SdkClientOption.ENDPOINT)).isEqualTo(ENDPOINT);
9192
}
9293

94+
@Test
95+
public void buildWithEndpointWithoutScheme_shouldThrowException() {
96+
assertThatThrownBy(() -> testClientBuilder().endpointOverride(URI.create("localhost")).build())
97+
.hasMessageContaining("The URI scheme of endpointOverride must not be null");
98+
99+
}
100+
93101
@Test
94102
public void noClientProvided_DefaultHttpClientIsManagedBySdk() {
95103
TestClient client = testClientBuilder().build();

0 commit comments

Comments
 (0)