From 887b3cd4906617660c2c16bf79db8a336abba90e Mon Sep 17 00:00:00 2001 From: Baljit Singh Date: Thu, 12 Oct 2023 12:18:03 -0400 Subject: [PATCH] use Apache HTTP client --- common/pom.xml | 2 +- .../common/AWSSchemaRegistryClient.java | 14 +++++++------- .../common/AWSSchemaRegistryClientTest.java | 2 +- .../GlueSchemaRegistryKafkaIntegrationTest.java | 3 --- .../GlueSchemaRegistryKinesisIntegrationTest.java | 3 --- 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/common/pom.xml b/common/pom.xml index 9ae68806..71af9ae3 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -76,7 +76,7 @@ software.amazon.awssdk - url-connection-client + apache-client org.apache.avro diff --git a/common/src/main/java/com/amazonaws/services/schemaregistry/common/AWSSchemaRegistryClient.java b/common/src/main/java/com/amazonaws/services/schemaregistry/common/AWSSchemaRegistryClient.java index 949e6563..b2ba2a0a 100644 --- a/common/src/main/java/com/amazonaws/services/schemaregistry/common/AWSSchemaRegistryClient.java +++ b/common/src/main/java/com/amazonaws/services/schemaregistry/common/AWSSchemaRegistryClient.java @@ -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; @@ -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); } diff --git a/common/src/test/java/com/amazonaws/services/schemaregistry/common/AWSSchemaRegistryClientTest.java b/common/src/test/java/com/amazonaws/services/schemaregistry/common/AWSSchemaRegistryClientTest.java index c6a221ae..7f0665a5 100644 --- a/common/src/test/java/com/amazonaws/services/schemaregistry/common/AWSSchemaRegistryClientTest.java +++ b/common/src/test/java/com/amazonaws/services/schemaregistry/common/AWSSchemaRegistryClientTest.java @@ -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()); } diff --git a/integration-tests/src/test/java/com/amazonaws/services/schemaregistry/integrationtests/kafka/GlueSchemaRegistryKafkaIntegrationTest.java b/integration-tests/src/test/java/com/amazonaws/services/schemaregistry/integrationtests/kafka/GlueSchemaRegistryKafkaIntegrationTest.java index 481932d6..c0a839a2 100644 --- a/integration-tests/src/test/java/com/amazonaws/services/schemaregistry/integrationtests/kafka/GlueSchemaRegistryKafkaIntegrationTest.java +++ b/integration-tests/src/test/java/com/amazonaws/services/schemaregistry/integrationtests/kafka/GlueSchemaRegistryKafkaIntegrationTest.java @@ -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; @@ -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) { diff --git a/integration-tests/src/test/java/com/amazonaws/services/schemaregistry/integrationtests/kinesis/GlueSchemaRegistryKinesisIntegrationTest.java b/integration-tests/src/test/java/com/amazonaws/services/schemaregistry/integrationtests/kinesis/GlueSchemaRegistryKinesisIntegrationTest.java index 68a03098..3e74b5cc 100644 --- a/integration-tests/src/test/java/com/amazonaws/services/schemaregistry/integrationtests/kinesis/GlueSchemaRegistryKinesisIntegrationTest.java +++ b/integration-tests/src/test/java/com/amazonaws/services/schemaregistry/integrationtests/kinesis/GlueSchemaRegistryKinesisIntegrationTest.java @@ -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; @@ -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) {