Skip to content

Commit

Permalink
use Apache HTTP client
Browse files Browse the repository at this point in the history
  • Loading branch information
singhbaljit committed Oct 12, 2023
1 parent a4923d4 commit 887b3cd
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>url-connection-client</artifactId>
<artifactId>apache-client</artifactId>
</dependency>
<dependency>
<groupId>org.apache.avro</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
import software.amazon.awssdk.core.interceptor.ExecutionAttributes;
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
import software.amazon.awssdk.core.retry.RetryPolicy;
import software.amazon.awssdk.http.urlconnection.ProxyConfiguration;
import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
import software.amazon.awssdk.http.apache.ApacheHttpClient;
import software.amazon.awssdk.http.apache.ProxyConfiguration;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.glue.GlueClient;
import software.amazon.awssdk.services.glue.GlueClientBuilder;
Expand Down Expand Up @@ -90,25 +90,25 @@ public AWSSchemaRegistryClient(@NonNull AwsCredentialsProvider credentialsProvid
.retryPolicy(retryPolicy)
.addExecutionInterceptor(new UserAgentRequestInterceptor())
.build();
UrlConnectionHttpClient.Builder urlConnectionHttpClientBuilder = UrlConnectionHttpClient.builder();
ApacheHttpClient.Builder httpClientBuilder = ApacheHttpClient.builder();
if (glueSchemaRegistryConfiguration.getProxyUrl() != null) {
log.debug("Creating http client using proxy {}", glueSchemaRegistryConfiguration.getProxyUrl().toString());
log.debug("Creating http client using proxy {}", glueSchemaRegistryConfiguration.getProxyUrl());
ProxyConfiguration proxy = ProxyConfiguration.builder().endpoint(glueSchemaRegistryConfiguration.getProxyUrl()).build();
urlConnectionHttpClientBuilder.proxyConfiguration(proxy);
httpClientBuilder.proxyConfiguration(proxy);
}

GlueClientBuilder glueClientBuilder = GlueClient
.builder()
.credentialsProvider(credentialsProvider)
.overrideConfiguration(overrideConfiguration)
.httpClient(urlConnectionHttpClientBuilder.build())
.httpClient(httpClientBuilder.build())
.region(Region.of(glueSchemaRegistryConfiguration.getRegion()));

if (glueSchemaRegistryConfiguration.getEndPoint() != null) {
try {
glueClientBuilder.endpointOverride(new URI(glueSchemaRegistryConfiguration.getEndPoint()));
} catch (URISyntaxException e) {
String message = String.format("Malformed uri, please pass the valid uri for creating the client",
String message = String.format("Malformed uri, please pass the valid uri for creating the client: %s",
glueSchemaRegistryConfiguration.getEndPoint());
throw new AWSSchemaRegistryException(message, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public void testConstructor_withMalformedUri_throwsException() {
() -> new AWSSchemaRegistryClient(mockAwsCredentialsProvider, glueSchemaRegistryConfiguration));
assertEquals(URISyntaxException.class, awsSchemaRegistryException.getCause().getClass());

String expectedMessage = String.format("Malformed uri, please pass the valid uri for creating the client",
String expectedMessage = String.format("Malformed uri, please pass the valid uri for creating the client: %s",
glueSchemaRegistryConfiguration.getEndPoint());
assertEquals(expectedMessage, awsSchemaRegistryException.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import org.junit.jupiter.params.provider.MethodSource;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.glue.GlueClient;
import software.amazon.awssdk.services.glue.model.Compatibility;
Expand Down Expand Up @@ -116,8 +115,6 @@ public static void tearDown() throws URISyntaxException {
.credentialsProvider(awsCredentialsProvider)
.region(Region.of(REGION))
.endpointOverride(new URI(SCHEMA_REGISTRY_ENDPOINT_OVERRIDE))
.httpClient(UrlConnectionHttpClient.builder()
.build())
.build();

for (String schemaName : schemasToCleanUp) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
import software.amazon.awssdk.core.SdkBytes;
import software.amazon.awssdk.core.SdkSystemSetting;
import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.cloudwatch.CloudWatchAsyncClient;
import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient;
Expand Down Expand Up @@ -195,8 +194,6 @@ public static void tearDown() throws URISyntaxException {
.credentialsProvider(awsCredentialsProvider)
.region(Region.of(REGION))
.endpointOverride(new URI(SCHEMA_REGISTRY_ENDPOINT_OVERRIDE))
.httpClient(UrlConnectionHttpClient.builder()
.build())
.build();

for (String schemaName : schemasToCleanUp) {
Expand Down

0 comments on commit 887b3cd

Please sign in to comment.