ソースを参照

HDFS-14482: Crash when using libhdfs with bad classpath

Sahil Takiar 6 年 前
コミット
e2dfdaee7c

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