From 2ee9ca37507f61c13a05ef6338260be4005f63b7 Mon Sep 17 00:00:00 2001 From: Mingyu Chen Date: Fri, 29 Mar 2024 11:34:18 +0800 Subject: [PATCH] [fix](jni) avoid coredump if failed to get jni env (#32950) This PR #32217 find a problem that may failed to get jni env. And it did a work around to avoid BE crash. This PR followup this issue, to avoid BE crash when doing `close()` of JniConnector if failed to get jni env. The `close()` method will return error when: 1. Failed to get jni env 2. Failed to release jni resource. This PR will ignore the first error, and still log fatal for second error --- be/src/vec/exec/jni_connector.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/be/src/vec/exec/jni_connector.cpp b/be/src/vec/exec/jni_connector.cpp index 5c85e329022b17..7ad6761523d162 100644 --- a/be/src/vec/exec/jni_connector.cpp +++ b/be/src/vec/exec/jni_connector.cpp @@ -58,11 +58,7 @@ namespace doris::vectorized { M(TypeIndex::Float64, Float64) JniConnector::~JniConnector() { - Status st = close(); - if (!st.ok()) { - // Ensure successful resource release - LOG(FATAL) << "Failed to release jni resource: " << st.to_string(); - } + static_cast(close()); } Status JniConnector::open(RuntimeState* state, RuntimeProfile* profile) { @@ -200,8 +196,9 @@ Status JniConnector::close() { _closed = true; jthrowable exc = (env)->ExceptionOccurred(); if (exc != nullptr) { - LOG(WARNING) << "Failed to release jni resource: " - << JniUtil::GetJniExceptionMsg(env).to_string(); + // Ensure successful resource release + LOG(FATAL) << "Failed to release jni resource: " + << JniUtil::GetJniExceptionMsg(env).to_string(); } } return Status::OK();