[fix](udf) fix java-udf coredump as get env return nullptr (#30986)

This commit is contained in:
zhangstar333
2024-02-19 17:19:05 +08:00
committed by yiguolei
parent 277de979c3
commit 8a3e6644d4
4 changed files with 13 additions and 12 deletions

View File

@ -126,29 +126,27 @@ private:
JniContext() = default;
void close() {
Status close() {
if (!open_successes) {
LOG_WARNING("maybe open failed, need check the reason");
return; //maybe open failed, so can't call some jni
return Status::OK(); //maybe open failed, so can't call some jni
}
if (is_closed) {
return;
return Status::OK();
}
VLOG_DEBUG << "Free resources for JniContext";
JNIEnv* env;
JNIEnv* env = nullptr;
Status status = JniUtil::GetJNIEnv(&env);
if (!status.ok()) {
if (!status.ok() || env == nullptr) {
LOG(WARNING) << "errors while get jni env " << status;
return;
return status;
}
env->CallNonvirtualVoidMethodA(executor, executor_cl, executor_close_id, nullptr);
env->DeleteGlobalRef(executor);
env->DeleteGlobalRef(executor_cl);
Status s = JniUtil::GetJniExceptionMsg(env);
if (!s.ok()) {
LOG(WARNING) << s;
}
RETURN_IF_ERROR(JniUtil::GetJniExceptionMsg(env));
is_closed = true;
return Status::OK();
}
};
};