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

a JVM leak that we cannot detected #362

Merged
merged 3 commits into from
Aug 2, 2021
Merged
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
10 changes: 7 additions & 3 deletions src/native/credentials_provider.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ static int s_credentials_provider_delegate_get_credentials(
callback_data->jni_delegate_credential_handler,
credentials_handler_properties.on_handler_get_credentials_method_id);
if (aws_jni_check_and_clear_exception(env)) {
goto call_failed;
goto fetch_credentials_failed;
}

jbyteArray java_access_key_id =
Expand All @@ -380,7 +380,7 @@ static int s_credentials_provider_delegate_get_credentials(
if (java_access_key_id == NULL || java_secret_access_key == NULL) {
aws_jni_throw_runtime_exception(
env, "DelegateCredentialProvider - accessKeyId and secretAccessKey must be non null");
goto call_failed;
goto empty_credentials;
}

struct aws_byte_cursor access_key_id = aws_jni_byte_cursor_from_jbyteArray_acquire(env, java_access_key_id);
Expand All @@ -407,7 +407,11 @@ static int s_credentials_provider_delegate_get_credentials(
if (java_session_token != NULL) {
aws_jni_byte_cursor_from_jbyteArray_release(env, java_session_token, session_token);
}
call_failed:
empty_credentials:
(*env)->DeleteLocalRef(env, java_access_key_id);
(*env)->DeleteLocalRef(env, java_secret_access_key);
(*env)->DeleteLocalRef(env, java_session_token);
fetch_credentials_failed:
(*env)->DeleteLocalRef(env, java_credentials);
return return_value;
}
Expand Down