{"record":{"id":"ee7f00f9d4dfd4f7","repo":"apache/hadoop","slug":"eio-ee7f00","errorCode":"-EIO","errorMessage":"testRecursiveJvmMutex: getJNIEnv failed\n","messagePattern":"testRecursiveJvmMutex: getJNIEnv failed\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/test_libhdfs_threaded.c","lineNumber":402,"sourceCode":"        fprintf(stderr, \"testLibHdfs: all threads succeeded.  SUCCESS.\\n\");\n        return EXIT_SUCCESS;\n    }\n    fprintf(stderr, \"testLibHdfs: some threads failed: [\");\n    for (i = 0; i < tlhNumThreads; i++) {\n        if (ti[i].success != 0) {\n            fprintf(stderr, \"%s%d\", sep, i);\n            sep = \", \";\n        }\n    }\n    fprintf(stderr, \"].  FAILURE.\\n\");\n    return EXIT_FAILURE;\n}\n\nint testRecursiveJvmMutex() {\n    jthrowable jthr;\n    JNIEnv *env = getJNIEnv();\n    if (!env) {\n        fprintf(stderr, \"testRecursiveJvmMutex: getJNIEnv failed\\n\");\n        return -EIO;\n    }\n    jthr = newRuntimeError(env, \"Dummy error to print for testing\");\n\n    /* printExceptionAndFree() takes the jvmMutex within */\n    mutexLock(&jvmMutex);\n    printExceptionAndFree(env, jthr, PRINT_EXC_ALL, \"testRecursiveJvmMutex\");\n    mutexUnlock(&jvmMutex);\n\n    return 0;\n}\n\n/**\n * Test that we can write a file with libhdfs and then read it back\n */\nint main(void)\n{\n    int i, tlhNumThreads;","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/test_libhdfs_threaded.c#L384-L420","documentation":"Error \"testRecursiveJvmMutex: getJNIEnv failed\n\" thrown in apache/hadoop.","triggerScenarios":"Raised in testRecursiveJvmMutex when getJNIEnv fails to obtain a JNI environment for the current thread.","commonSituations":"Occurs when the cached JVM reference is NULL or thread attach failed, typically because hdfsBuilderConnect was never called or the JVM was destroyed.","solutions":["Ensure the JVM was created with enough capacity for another thread attach (check globalJVM/JVM reference count in the test).","Verify the current native thread is allowed to attach: JNIInvokeInterface must not have been destroyed mid-test.","Check that hdfsThreadDomains/mutex initialization (hdfsThreadOnce) completed successfully before this test runs."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}