This is an automated email from the ASF dual-hosted git repository. lihaopeng pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push: new ff523385073 [bug](udaf) jni call get error and return without delete (#31399) ff523385073 is described below commit ff523385073eccfdc8aa7743ea32c1632b87acac Author: zhangstar333 <87313068+zhangstar...@users.noreply.github.com> AuthorDate: Mon Feb 26 18:03:27 2024 +0800 [bug](udaf) jni call get error and return without delete (#31399) --- .../vec/aggregate_functions/aggregate_function_java_udaf.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/be/src/vec/aggregate_functions/aggregate_function_java_udaf.h b/be/src/vec/aggregate_functions/aggregate_function_java_udaf.h index defd33b4754..66801b824d4 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_java_udaf.h +++ b/be/src/vec/aggregate_functions/aggregate_function_java_udaf.h @@ -59,13 +59,20 @@ public: AggregateJavaUdafData(int64_t num_args) { argument_size = num_args; } ~AggregateJavaUdafData() { - JNIEnv* env; + JNIEnv* env = nullptr; + //use defer as the jni call maybe have error, then directly return without delete + Defer defer([&, this] { + std::string temp; + temp.swap(serialize_data); + if (env != nullptr) { + env->DeleteGlobalRef(executor_cl); + env->DeleteGlobalRef(executor_obj); + } + }); Status status; RETURN_IF_STATUS_ERROR(status, JniUtil::GetJNIEnv(&env)); env->CallNonvirtualVoidMethod(executor_obj, executor_cl, executor_close_id); RETURN_IF_STATUS_ERROR(status, JniUtil::GetJniExceptionMsg(env)); - env->DeleteGlobalRef(executor_cl); - env->DeleteGlobalRef(executor_obj); } Status init_udaf(const TFunction& fn, const std::string& local_location) { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org