[fix](udf) fix java-udf coredump as get env return nullptr (#30986)
This commit is contained in:
@ -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();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user