Skip to content

Commit

Permalink
Mismatched JNI call on proxy auth enum (#779)
Browse files Browse the repository at this point in the history
Co-authored-by: Bret Ambrose <bambrose@amazon.com>
  • Loading branch information
bretambrose and Bret Ambrose authored Apr 17, 2024
1 parent 9360cfd commit 5d62d97
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/native/java_class_ids.c
Original file line number Diff line number Diff line change
Expand Up @@ -1480,6 +1480,19 @@ static void s_cache_http_proxy_connection_type(JNIEnv *env) {
AWS_FATAL_ASSERT(http_proxy_connection_type_properties.proxy_get_value_id);
}

struct java_aws_http_proxy_authorization_type_properties http_proxy_authorization_type_properties;

static void s_cache_http_proxy_authorization_type(JNIEnv *env) {
jclass cls = (*env)->FindClass(env, "software/amazon/awssdk/crt/http/HttpProxyOptions$HttpProxyAuthorizationType");
AWS_FATAL_ASSERT(cls);
http_proxy_authorization_type_properties.http_proxy_authorization_type_class = (*env)->NewGlobalRef(env, cls);
AWS_FATAL_ASSERT(http_proxy_authorization_type_properties.http_proxy_authorization_type_class);
// Functions
http_proxy_authorization_type_properties.proxy_get_value_id = (*env)->GetMethodID(
env, http_proxy_authorization_type_properties.http_proxy_authorization_type_class, "getValue", "()I");
AWS_FATAL_ASSERT(http_proxy_authorization_type_properties.proxy_get_value_id);
}

struct java_aws_mqtt5_client_options_properties mqtt5_client_options_properties;

static void s_cache_mqtt5_client_options(JNIEnv *env) {
Expand Down Expand Up @@ -2372,6 +2385,7 @@ static void s_cache_java_class_ids(void *user_data) {
s_cache_mqtt5_negotiated_settings(env);
s_cache_http_proxy_options(env);
s_cache_http_proxy_connection_type(env);
s_cache_http_proxy_authorization_type(env);
s_cache_mqtt5_client_options(env);
s_cache_mqtt5_client_properties(env);
s_cache_mqtt5_client_operation_statistics_properties(env);
Expand Down
7 changes: 7 additions & 0 deletions src/native/java_class_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,13 @@ struct java_aws_http_proxy_connection_type_properties {
};
extern struct java_aws_http_proxy_connection_type_properties http_proxy_connection_type_properties;

/* http.HttpProxyOptions.HttpProxyAuthorizationType */
struct java_aws_http_proxy_authorization_type_properties {
jclass http_proxy_authorization_type_class;
jmethodID proxy_get_value_id;
};
extern struct java_aws_http_proxy_authorization_type_properties http_proxy_authorization_type_properties;

/* mqtt5.ClientOptions */
struct java_aws_mqtt5_client_options_properties {
jclass client_options_class;
Expand Down
2 changes: 1 addition & 1 deletion src/native/mqtt5_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ static struct aws_http_proxy_options_java_jni *s_aws_mqtt5_http_proxy_options_cr
}
if (jni_proxy_authorization_type) {
jint jni_proxy_authorization_type_value = (*env)->CallIntMethod(
env, jni_proxy_authorization_type, http_proxy_connection_type_properties.proxy_get_value_id);
env, jni_proxy_authorization_type, http_proxy_authorization_type_properties.proxy_get_value_id);
if (aws_jni_check_and_clear_exception(env)) {
goto on_error;
}
Expand Down

0 comments on commit 5d62d97

Please sign in to comment.