apache/hadoop · error · IOException

invalid arguments to createHardLinkMult: filename list can…

Error message

invalid arguments to createHardLinkMult: filename list can be empty but not null

What it means

HardLink.createHardLinkMult argument guard: fileBaseNames is null; an empty filename list is tolerated (nothing to link) but null is not, because it signals the caller never obtained a listing from parentDir.list().

Solutions

  1. Pass an empty array instead of null for the filename list.
  2. Initialize the filename list before calling createHardLinkMult.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HardLink.java:203 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/a941f34bd7ee8577. Report an issue: GitHub.

Appendix: source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HardLink.java:203

   * directory, into one target directory.
   * @param parentDir - directory containing source files
   * @param fileBaseNames - list of path-less file names, as returned by 
   *                        parentDir.list()
   * @param linkDir - where the hardlinks should be put. It must already exist.
   * @throws IOException raised on errors performing I/O.
   */
  public static void createHardLinkMult(File parentDir, String[] fileBaseNames,
      File linkDir) throws IOException {
    if (parentDir == null) {
      throw new IOException(
          "invalid arguments to createHardLinkMult: parent directory is null");
    }
    if (linkDir == null) {
      throw new IOException(
          "invalid arguments to createHardLinkMult: link directory is null");
    }
    if (fileBaseNames == null) {
      throw new IOException(
          "invalid arguments to createHardLinkMult: "
          + "filename list can be empty but not null");
    }
    if (!linkDir.exists()) {
      throw new FileNotFoundException(linkDir + " not found.");
    }
    for (String name : fileBaseNames) {
      createLink(linkDir.toPath().resolve(name),
                 parentDir.toPath().resolve(name));
    }
  }

    /**
     * Determines whether the system supports hardlinks.
     * @param f - file to examine
     * @return true if hardlinks are supported, false otherwise
     */
  public static boolean supportsHardLink(File f) {

View on GitHub (pinned to 2add963021)