diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/os/posix/thread_local_storage.c b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/os/posix/thread_local_storage.c index a0f26c6cb6..1b6dafaba8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/os/posix/thread_local_storage.c +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/os/posix/thread_local_storage.c @@ -53,7 +53,7 @@ void hdfsThreadDestructor(void *v) char thr_name[MAXTHRID]; /* Detach the current thread from the JVM */ - if (env) { + if ((env != NULL) && (*env != NULL)) { ret = (*env)->GetJavaVM(env, &vm); if (ret != 0) { diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/os/windows/thread_local_storage.c b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/os/windows/thread_local_storage.c index a6f48fd4a8..f7abc89908 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/os/windows/thread_local_storage.c +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/os/windows/thread_local_storage.c @@ -46,10 +46,10 @@ static void detachCurrentThreadFromJvm() if (threadLocalStorageGet(&state) || !state) { return; } - if (!state->env) { + env = state->env; + if ((env == NULL) || (*env == NULL)) { return; } - env = state->env; ret = (*env)->GetJavaVM(env, &vm); if (ret) { fprintf(stderr,