apache/hadoop · error · UnsupportedOperationException

Not implemented for Windows

Error message

Not implemented for Windows

What it means

FileUtil.makeSecureShellPath(File) throws UnsupportedOperationException("Not implemented for Windows") whenever Shell.WINDOWS is true. The method shell-escapes single quotes for POSIX shells (makeShellPath(file, false).replace("'", "'\\''")), which has no correct Windows equivalent, so it refuses rather than producing an injectable string. The code comment states it is currently never called internally. It is a hard capability gap, not an environmental glitch.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java:682

   * @param file The filename to convert
   * @return The unix pathname
   * @throws IOException on windows, there can be problems with the subprocess
   */
  public static String makeShellPath(File file) throws IOException {
    return makeShellPath(file, false);
  }

  /**
   * Convert a os-native filename to a path that works for the shell
   * and avoids script injection attacks.
   * @param file The filename to convert
   * @return The unix pathname
   * @throws IOException on windows, there can be problems with the subprocess
   */
  public static String makeSecureShellPath(File file) throws IOException {
    if (Shell.WINDOWS) {
      // Currently it is never called, but it might be helpful in the future.
      throw new UnsupportedOperationException("Not implemented for Windows");
    } else {
      return makeShellPath(file, false).replace("'", "'\\''");
    }
  }

  /**
   * Convert a os-native filename to a path that works for the shell.
   * @param file The filename to convert
   * @param makeCanonicalPath
   *          Whether to make canonical path for the file passed
   * @return The unix pathname
   * @throws IOException on windows, there can be problems with the subprocess
   */
  public static String makeShellPath(File file, boolean makeCanonicalPath)
  throws IOException {
    if (makeCanonicalPath) {
      return makeShellPath(file.getCanonicalPath());
    } else {

View on GitHub (pinned to 2add963021)

Solutions

  1. Guard the call: only invoke makeSecureShellPath when !Shell.WINDOWS, and use a Windows-safe quoting routine otherwise
  2. Avoid shelling out on Windows entirely; use ProcessBuilder with an argument list (no shell string) which removes the need for shell escaping
  3. If you must run a POSIX shell path, run the logic on a Linux host/container instead of the Windows node

Example fix

// before
String safe = FileUtil.makeSecureShellPath(file); // throws on Windows

// after
String safe = !Shell.WINDOWS
    ? FileUtil.makeSecureShellPath(file)
    : "\"" + file.getAbsolutePath().replace("\"", "\"\"") + "\"";
Defensive patterns

Strategy: validation

Validate before calling

if (!Shell.WINDOWS) {
  shellPath = FileUtil.makeSecureShellPath(file);
} else {
  // build argv for ProcessBuilder instead; no shell string to escape
}

Type guard

static boolean supportsSecureShellPath() {
  return !Shell.WINDOWS;
}

Try / catch

try {
  path = FileUtil.makeSecureShellPath(file);
} catch (UnsupportedOperationException e) {
  // Windows: fall back to ProcessBuilder argument-array invocation
}

Prevention

When it happens

Trigger: Invoking FileUtil.makeSecureShellPath(file) on any Windows host or Windows CI runner; library code paths that build bash command lines running under cygwin-class environments where Shell.WINDOWS is detected.

Common situations: Cross-platform tooling tested on Linux but deployed on Windows nodes; unit tests executing on Windows CI; shell-injection-hardening refactors that adopt this helper without platform gating.

Related errors


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