{"record":{"id":"cb255f0aac4bbaf9","repo":"apache/hadoop","slug":"einternal","errorCode":"EINTERNAL","errorMessage":"hdfsGetHosts(path=%s, start=%\"PRId64\", length=%\"PRId64\"): BlockLocation#getHosts returned NULL","messagePattern":"hdfsGetHosts\\(path=(.+?), start=%\"PRId64\", length=%\"PRId64\"\\): BlockLocation#getHosts returned NULL","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/hdfs.c","lineNumber":3786,"sourceCode":"        if (jthr || !jFileBlock) {\n            ret = printExceptionAndFree(env, jthr, PRINT_EXC_ALL,\n                \"hdfsGetHosts(path=%s, start=%\"PRId64\", length=%\"PRId64\"):\"\n                \"GetObjectArrayElement(%d)\", path, start, length, i);\n            goto done;\n        }\n        \n        jthr = invokeMethod(env, &jVal, INSTANCE, jFileBlock,\n                JC_BLOCK_LOCATION, \"getHosts\",\n                \"()[Ljava/lang/String;\");\n        if (jthr) {\n            ret = printExceptionAndFree(env, jthr, PRINT_EXC_ALL,\n                \"hdfsGetHosts(path=%s, start=%\"PRId64\", length=%\"PRId64\"):\"\n                \"BlockLocation#getHosts\", path, start, length);\n            goto done;\n        }\n        jFileBlockHosts = jVal.l;\n        if (!jFileBlockHosts) {\n            fprintf(stderr,\n                \"hdfsGetHosts(path=%s, start=%\"PRId64\", length=%\"PRId64\"):\"\n                \"BlockLocation#getHosts returned NULL\", path, start, length);\n            ret = EINTERNAL;\n            goto done;\n        }\n        //Figure out no of hosts in jFileBlockHosts, and allocate the memory\n        jNumBlockHosts = (*env)->GetArrayLength(env, jFileBlockHosts);\n        blockHosts[i] = calloc(jNumBlockHosts + 1, sizeof(char*));\n        if (!blockHosts[i]) {\n            ret = ENOMEM;\n            goto done;\n        }\n\n        //Now parse each hostname\n        for (j = 0; j < jNumBlockHosts; ++j) {\n            jHost = (*env)->GetObjectArrayElement(env, jFileBlockHosts, j);\n            jthr = (*env)->ExceptionOccurred(env);\n            if (jthr || !jHost) {","sourceCodeStart":3768,"sourceCodeEnd":3804,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/hdfs.c#L3768-L3804","documentation":"hdfsGetHosts walks the file's BlockLocation[] and calls BlockLocation#getHosts over JNI for each block. Java normally returns an array (possibly empty), so a null return signals a broken implementation or bad JVM state; libhdfs reports EINTERNAL with the path and the start/length range in the message.","triggerScenarios":"Version mismatch between the native libhdfs and the hadoop-hdfs jars on CLASSPATH; custom BlockLocation implementations; JVM state corrupted by earlier pending exceptions.","commonSituations":"Client machines with stale Hadoop jars; data-locality probes (HBase-style region placement) in mixed-version clusters; shaded Hadoop classes inside embedding frameworks.","solutions":["Align the libhdfs native library version with the hadoop jars of the same distribution","Generate CLASSPATH with `hadoop classpath` from the matching installation","Treat EINTERNAL from this call as non-retryable and report the file and range from the message"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"if (hdfsGetHosts(fs, path, start, length, &hosts) == -1) {\n    /* EINTERNAL: JVM returned null; treat as unavailable, do not retry the same call */\n    hosts = NULL;  /* proceed without locality info */\n}","preventionTips":["Keep libhdfs.so and hadoop jars from the same distribution","Generate CLASSPATH with `hadoop classpath` from the matching install","Design locality-aware callers to degrade gracefully when host info is unavailable"],"tags":["hdfs","libhdfs","jni","block-location","data-locality"],"backgroundTag":"jni-null-return","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}