{"record":{"id":"4bf94f38c1b9c123","repo":"apache/hadoop","slug":"invalid-argument-to-getlinkcount-file-name-is-nul","errorCode":null,"errorMessage":"invalid argument to getLinkCount: file name is null","messagePattern":"invalid argument to getLinkCount: file name is null","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HardLink.java","lineNumber":240,"sourceCode":"    try {\n      FileStore store = Files.getFileStore(f.toPath());\n      return store.supportsFileAttributeView(FILE_ATTRIBUTE_VIEW);\n    } catch (IOException e) {\n      LOG.warn(\"Failed to determine if hardlink is supported\", e);\n      return false;\n    }\n  }\n\n   /**\n   * Retrieves the number of links to the specified file.\n    *\n    * @param fileName file name.\n    * @throws IOException raised on errors performing I/O.\n    * @return link count.\n   */\n  public static int getLinkCount(File fileName) throws IOException {\n    if (fileName == null) {\n      throw new IOException(\n          \"invalid argument to getLinkCount: file name is null\");\n    }\n    if (!fileName.exists()) {\n      throw new FileNotFoundException(fileName + \" not found.\");\n    }\n\n    if (supportsHardLink(fileName)) {\n      return (int) Files.getAttribute(fileName.toPath(), FILE_ATTRIBUTE);\n    }\n\n    // construct and execute shell command\n    String[] cmd = getHardLinkCommand.linkCount(fileName);\n    String inpMsg = null;\n    String errMsg = null;\n    int exitValue = -1;\n    BufferedReader in = null;\n\n    ShellCommandExecutor shexec = new ShellCommandExecutor(cmd);","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HardLink.java#L222-L258","documentation":"Error \"invalid argument to getLinkCount: file name is null\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HardLink.java:240 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a non-null File to getLinkCount.","Validate the file path before querying link count."],"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"}