You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by kw...@apache.org on 2019/02/27 04:12:38 UTC

[impala] 03/03: IMPALA-8250: Fix a handful of JNI usage errors.

This is an automated email from the ASF dual-hosted git repository.

kwho pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit b74d63222875482c7efe38b8b2e5ff091a94fb6a
Author: Philip Zeyliger <ph...@cloudera.com>
AuthorDate: Mon Feb 25 15:44:46 2019 -0800

    IMPALA-8250: Fix a handful of JNI usage errors.
    
    Running Impala with LIB_HDFS_OPTS=-Xcheck:jni revealed a case of "FATAL
    ERROR in native method: Bad global or local ref passed to JNI" as well
    as 'WARNING in native method: JNI FindClass received a bad class
    descriptor "Lorg/apache/impala/common/Pair;"' This commit fixes these.
    
    There are additional JNI warnings that I'm working through
    as well as a fundamental question about how to avoid these
    systematically.
    
    Kudos to Lars Volker and Sahil Takiar who co-found these issues.
    
    Change-Id: Id3b8bccee20cc882cffa4439e550e1f48347d3a6
    Reviewed-on: http://gerrit.cloudera.org:8080/12582
    Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
 be/src/catalog/catalog-util.cc | 4 ++--
 be/src/util/logging-support.cc | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/be/src/catalog/catalog-util.cc b/be/src/catalog/catalog-util.cc
index 2a3f1ae..d2b027b 100644
--- a/be/src/catalog/catalog-util.cc
+++ b/be/src/catalog/catalog-util.cc
@@ -46,12 +46,12 @@ Status JniCatalogCacheUpdateIterator::InitJNI() {
   JNIEnv* env = getJNIEnv();
   if (env == nullptr) return Status("Failed to get/create JVM");
   RETURN_IF_ERROR(
-      JniUtil::GetGlobalClassRef(env, "Lorg/apache/impala/common/Pair;", &pair_cl));
+      JniUtil::GetGlobalClassRef(env, "org/apache/impala/common/Pair", &pair_cl));
   pair_ctor = env->GetMethodID(pair_cl, "<init>",
       "(Ljava/lang/Object;Ljava/lang/Object;)V");
   RETURN_ERROR_IF_EXC(env);
   RETURN_IF_ERROR(
-      JniUtil::GetGlobalClassRef(env, "Ljava/lang/Boolean;", &boolean_cl));
+      JniUtil::GetGlobalClassRef(env, "java/lang/Boolean", &boolean_cl));
   boolean_ctor = env->GetMethodID(boolean_cl, "<init>", "(Z)V");
   RETURN_ERROR_IF_EXC(env);
   return Status::OK();
diff --git a/be/src/util/logging-support.cc b/be/src/util/logging-support.cc
index 8281487..97dba25 100644
--- a/be/src/util/logging-support.cc
+++ b/be/src/util/logging-support.cc
@@ -109,8 +109,8 @@ Webserver::UrlCallback MakeCallback(const F& fnc, bool display_log4j_handlers) {
 
 void InitDynamicLoggingSupport() {
   JNIEnv* env = getJNIEnv();
-  log4j_logger_class_ = env->FindClass("org/apache/impala/util/GlogAppender");
-  ABORT_IF_EXC(env);
+  ABORT_IF_ERROR(JniUtil::GetGlobalClassRef(env, "org/apache/impala/util/GlogAppender",
+        &log4j_logger_class_));
   JniMethodDescriptor get_log_level_method_desc =
       {"getLogLevel", "([B)Ljava/lang/String;", &get_log_level_method};
   JniMethodDescriptor set_log_level_method_desc =