From 26aa1ffbd9bcb0aaa9a684d62b9bdbd58857c88d Mon Sep 17 00:00:00 2001 From: Mike Schore Date: Tue, 24 Aug 2021 10:51:29 -0700 Subject: [PATCH] jni: clean up several instances of unused jclass refs (#1743) Signed-off-by: Mike Schore Signed-off-by: JP Simard --- mobile/library/common/jni/jni_interface.cc | 7 ------- 1 file changed, 7 deletions(-) diff --git a/mobile/library/common/jni/jni_interface.cc b/mobile/library/common/jni/jni_interface.cc index 64b95e6278d1..fd89f16990ee 100644 --- a/mobile/library/common/jni/jni_interface.cc +++ b/mobile/library/common/jni/jni_interface.cc @@ -776,8 +776,6 @@ extern "C" JNIEXPORT jlong JNICALL Java_io_envoyproxy_envoymobile_engine_JniLibr extern "C" JNIEXPORT jint JNICALL Java_io_envoyproxy_envoymobile_engine_JniLibrary_startStream( JNIEnv* env, jclass, jlong stream_handle, jobject j_context, jboolean explicit_flow_control) { - jclass jcls_JvmCallbackContext = env->GetObjectClass(j_context); - // TODO: To be truly safe we may need stronger guarantees of operation ordering on this ref. jobject retained_context = env->NewGlobalRef(j_context); envoy_http_callbacks native_callbacks = {jvm_on_response_headers, @@ -794,7 +792,6 @@ extern "C" JNIEXPORT jint JNICALL Java_io_envoyproxy_envoymobile_engine_JniLibra if (result != ENVOY_SUCCESS) { env->DeleteGlobalRef(retained_context); // No callbacks are fired and we need to release } - env->DeleteLocalRef(jcls_JvmCallbackContext); return result; } @@ -809,7 +806,6 @@ Java_io_envoyproxy_envoymobile_engine_JniLibrary_registerFilterFactory(JNIEnv* e // This will need to be updated for https://github.com/lyft/envoy-mobile/issues/332 jni_log("[Envoy]", "registerFilterFactory"); jni_log_fmt("[Envoy]", "j_context: %p", j_context); - jclass jcls_JvmFilterFactoryContext = env->GetObjectClass(j_context); jobject retained_context = env->NewGlobalRef(j_context); jni_log_fmt("[Envoy]", "retained_context: %p", retained_context); envoy_http_filter* api = (envoy_http_filter*)safe_malloc(sizeof(envoy_http_filter)); @@ -831,7 +827,6 @@ Java_io_envoyproxy_envoymobile_engine_JniLibrary_registerFilterFactory(JNIEnv* e api->instance_context = NULL; envoy_status_t result = register_platform_api(env->GetStringUTFChars(filter_name, nullptr), api); - env->DeleteLocalRef(jcls_JvmFilterFactoryContext); return result; } @@ -932,7 +927,6 @@ Java_io_envoyproxy_envoymobile_engine_JniLibrary_registerStringAccessor(JNIEnv* // TODO(goaway): The retained_context leaks, but it's tied to the life of the engine. // This will need to be updated for https://github.com/lyft/envoy-mobile/issues/332. - jclass jcls_JvmStringAccessorContext = env->GetObjectClass(j_context); jobject retained_context = env->NewGlobalRef(j_context); envoy_string_accessor* string_accessor = @@ -942,7 +936,6 @@ Java_io_envoyproxy_envoymobile_engine_JniLibrary_registerStringAccessor(JNIEnv* envoy_status_t result = register_platform_api(env->GetStringUTFChars(accessor_name, nullptr), string_accessor); - env->DeleteLocalRef(jcls_JvmStringAccessorContext); return result; }