Skip to content

Commit df13605

Browse files
committed
made changes for URL client
1 parent 296dbc1 commit df13605

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

http-clients/url-connection-client/src/main/java/software/amazon/awssdk/http/urlconnection/UrlConnectionHttpClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ public interface Builder extends SdkHttpClient.Builder<UrlConnectionHttpClient.B
503503

504504
private static final class DefaultBuilder implements Builder {
505505
private final AttributeMap.Builder standardOptions = AttributeMap.builder();
506-
private ProxyConfiguration proxyConfiguration;
506+
private ProxyConfiguration proxyConfiguration = ProxyConfiguration.builder().build();
507507

508508
private DefaultBuilder() {
509509
}

test/http-client-tests/src/main/java/software/amazon/awssdk/http/proxy/HttpClientDefaultPoxyConfigTest.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.util.Collections;
3131
import java.util.List;
3232
import java.util.Map;
33+
import java.util.Random;
3334
import java.util.concurrent.CompletableFuture;
3435
import java.util.concurrent.ThreadLocalRandom;
3536
import java.util.concurrent.TimeUnit;
@@ -61,6 +62,8 @@
6162

6263
public abstract class HttpClientDefaultPoxyConfigTest {
6364

65+
static Random random = new Random();
66+
6467
private static final EnvironmentVariableHelper ENVIRONMENT_VARIABLE_HELPER = new EnvironmentVariableHelper();
6568

6669
protected WireMockServer mockProxy = new WireMockServer(new WireMockConfiguration()
@@ -206,9 +209,14 @@ public void defaultProxyConfigurationSyncHttp(SdkHttpClient client, Class<? exte
206209
.request(request)
207210
.build());
208211

209-
if (exceptionType != null && proxyFailedCauseExceptionType != null) {
210-
assertThatExceptionOfType(exceptionType).isThrownBy(() -> executableHttpRequest.call())
211-
.withCauseInstanceOf(proxyFailedCauseExceptionType);
212+
if (exceptionType != null) {
213+
if (proxyFailedCauseExceptionType != null) {
214+
assertThatExceptionOfType(exceptionType).isThrownBy(() -> executableHttpRequest.call())
215+
.withCauseInstanceOf(proxyFailedCauseExceptionType);
216+
} else {
217+
218+
assertThatExceptionOfType(exceptionType).isThrownBy(() -> executableHttpRequest.call());
219+
}
212220
} else {
213221
HttpExecuteResponse executeResponse = executableHttpRequest.call();
214222
assertThat(error.get()).isNull();
@@ -284,7 +292,7 @@ static SdkHttpFullRequest createRequest(URI endpoint,
284292
private int getRandomPort(int currentPort) {
285293
int randomPort;
286294
do {
287-
randomPort = ThreadLocalRandom.current().nextInt(65535);
295+
randomPort = random.nextInt(65535);
288296
} while (randomPort == currentPort);
289297
return randomPort;
290298
}

0 commit comments

Comments
 (0)