Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use Apache HTTP client #303

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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