Skip to content

Commit

Permalink
Fix tls_ctx memleak in s3 client creation (#824)
Browse files Browse the repository at this point in the history
Co-authored-by: Paul Praet <3198728+praetp@users.noreply.github.com>
  • Loading branch information
waahm7 and praetp authored Aug 23, 2024
1 parent 9861cd7 commit c66582f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
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

0 comments on commit c66582f

Please sign in to comment.