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

Fix tls_ctx memleak in s3 client creation #824

Merged
merged 3 commits into from
Aug 23, 2024
Merged
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 crt/s2n
Submodule s2n updated from 79c0f1 to 87f4a0
4 changes: 3 additions & 1 deletion src/native/s3_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,9 @@ JNIEXPORT jlong JNICALL Java_software_amazon_awssdk_crt_s3_S3Client_s3ClientNew(
env, &proxy_options, jni_proxy_host, jni_proxy_authorization_username, jni_proxy_authorization_password);

aws_mem_release(aws_jni_get_allocator(), s3_tcp_keep_alive_options);

if (tls_options) {
aws_tls_connection_options_clean_up(tls_options);
}
return (jlong)client;
}

Expand Down
20 changes: 18 additions & 2 deletions src/test/java/software/amazon/awssdk/crt/test/S3ClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,21 @@ public void testS3ClientCreateDestroy() {

}
}

@Test
public void testS3ClientCreateDestroyWithTLS() {
skipIfAndroid();
skipIfNetworkUnavailable();

try (TlsContextOptions tlsContextOptions = TlsContextOptions.createDefaultClient();
TlsContext tlsContext = new TlsContext(tlsContextOptions);) {
S3ClientOptions clientOptions = new S3ClientOptions()
.withRegion(REGION)
.withTlsContext(tlsContext);
try (S3Client client = createS3Client(clientOptions)) {
}
}
}

@Test
public void testS3ClientCreateDestroyWithCredentialsProvider() {
Expand Down Expand Up @@ -260,8 +275,9 @@ public void testS3ClientCreateDestroyHttpProxyOptions() {
proxyOptions.setAuthorizationType(HttpProxyOptions.HttpProxyAuthorizationType.Basic);
proxyOptions.setAuthorizationUsername("username");
proxyOptions.setAuthorizationPassword("password");
try (S3Client client = createS3Client(new S3ClientOptions().withRegion(REGION)
.withProxyOptions(proxyOptions), elg)) {
try (S3Client client = createS3Client(new S3ClientOptions()
.withRegion(REGION)
.withProxyOptions(proxyOptions), elg)) {
}
}
}
Expand Down
Loading