浏览代码

HDFS-14482: Crash when using libhdfs with bad classpath

Sahil Takiar 6 年之前
父节点
当前提交
e2dfdaee7c
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. 4 4
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/jni_helper.c

+ 4 - 4
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/jni_helper.c

@@ -551,6 +551,10 @@ JNIEnv* getJNIEnv(void)
     state->env = getGlobalJNIEnv();
     state->env = getGlobalJNIEnv();
     mutexUnlock(&jvmMutex);
     mutexUnlock(&jvmMutex);
 
 
+    if (!state->env) {
+        goto fail;
+    }
+
     jthrowable jthr = NULL;
     jthrowable jthr = NULL;
     jthr = initCachedClasses(state->env);
     jthr = initCachedClasses(state->env);
     if (jthr) {
     if (jthr) {
@@ -558,10 +562,6 @@ JNIEnv* getJNIEnv(void)
                             "initCachedClasses failed");
                             "initCachedClasses failed");
       goto fail;
       goto fail;
     }
     }
-
-    if (!state->env) {
-      goto fail;
-    }
     return state->env;
     return state->env;
 
 
 fail:
 fail: