Skip to content

Commit

Permalink
jni: clean up several instances of unused jclass refs (#1743)
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: JP Simard <jp@jpsim.com>
  • Loading branch information
goaway authored and jpsim committed Nov 28, 2022
1 parent 97461b8 commit 26aa1ff
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions mobile/library/common/jni/jni_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
}

Expand All @@ -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));
Expand All @@ -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;
}

Expand Down Expand Up @@ -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 =
Expand All @@ -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;
}

Expand Down

0 comments on commit 26aa1ff

Please sign in to comment.