You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gluten.apache.org by ho...@apache.org on 2026/02/27 10:34:49 UTC
(incubator-gluten) branch main updated: [GLUTEN-11513][CORE] Add null checks and improve JNI listener initialization in JniCommon.h (#11664)
This is an automated email from the ASF dual-hosted git repository.
hongze pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git
The following commit(s) were added to refs/heads/main by this push:
new 7c069da5d6 [GLUTEN-11513][CORE] Add null checks and improve JNI listener initialization in JniCommon.h (#11664)
7c069da5d6 is described below
commit 7c069da5d6ca5ff8ce9749aced2952c55205ab2a
Author: Reema Alzaid <80...@users.noreply.github.com>
AuthorDate: Fri Feb 27 13:34:43 2026 +0300
[GLUTEN-11513][CORE] Add null checks and improve JNI listener initialization in JniCommon.h (#11664)
---
cpp/core/jni/JniCommon.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/cpp/core/jni/JniCommon.h b/cpp/core/jni/JniCommon.h
index 1044edb6d7..783f8edfcc 100644
--- a/cpp/core/jni/JniCommon.h
+++ b/cpp/core/jni/JniCommon.h
@@ -99,6 +99,9 @@ static inline jmethodID getMethodId(JNIEnv* env, jclass thisClass, const char* n
}
static inline jmethodID getMethodIdOrError(JNIEnv* env, jclass thisClass, const char* name, const char* sig) {
+ if (thisClass == nullptr) {
+ throw gluten::GlutenException("Unable to find class while looking up method " + std::string(name));
+ }
jmethodID ret = getMethodId(env, thisClass, name, sig);
if (ret == nullptr) {
std::string errorMessage = "Unable to find method " + std::string(name) + " within signature" + std::string(sig);
@@ -376,6 +379,10 @@ class SparkAllocationListener final : public gluten::AllocationListener {
JNIEnv* env;
attachCurrentThreadAsDaemonOrThrow(vm_, &env);
jListenerGlobalRef_ = env->NewGlobalRef(jListenerLocalRef);
+ GLUTEN_CHECK(jListenerGlobalRef_ != nullptr, "Failed to create global reference for reservation listener.");
+ // Resolve JNI symbols on the creator thread to avoid first-touch initialization from IO threads.
+ (void)reserveMemoryMethod(env);
+ (void)unreserveMemoryMethod(env);
}
SparkAllocationListener(const SparkAllocationListener&) = delete;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org