shwenzhang/AndResGuard · error · java.io.IOException

Failed to read : standard input closed

Error message

Failed to read ${description}: standard input closed

What it means

Thrown by PasswordRetriever.getPasswords for the 'stdin' password spec: no Console exists, so the password is read from redirected standard input, but the encoded bytes read were empty (stdin was closed or nothing was piped). It signals that the caller promised a password via stdin but delivered none — an environment/input error, not an authentication failure.

Solutions

  1. Provide the password on standard input (e.g. echo the password or redirect a file containing it) instead of leaving stdin closed
  2. Use an alternative password spec such as pass:<password>, file:<path>, or env:<variable> when stdin is not attached
  3. Verify the process was launched with stdin connected to a pipe or terminal that delivers data
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at AndResGuard-core/src/main/java/apksigner/PasswordRetriever.java:296 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of shwenzhang/AndResGuard@e4df245d82 (2026-09-12). Data as JSON: /api/errors/647fe823088ab4e8. Report an issue: GitHub.

Appendix: source

Thrown at AndResGuard-core/src/main/java/apksigner/PasswordRetriever.java:296

    assertNotClosed();
    if (spec.startsWith("pass:")) {
      char[] pwd = spec.substring("pass:".length()).toCharArray();
      return getPasswords(pwd);
    } else if (SPEC_STDIN.equals(spec)) {
      Console console = System.console();
      if (console != null) {
        // Reading from console
        char[] pwd = console.readPassword(description + ": ");
        if (pwd == null) {
          throw new IOException("Failed to read " + description + ": console closed");
        }
        return getPasswords(pwd);
      } else {
        // Console not available -- reading from redirected input
        System.out.println(description + ": ");
        byte[] encodedPwd = readEncodedPassword(System.in);
        if (encodedPwd.length == 0) {
          throw new IOException("Failed to read " + description + ": standard input closed");
        }
        // By default, textual input obtained via standard input is supposed to be decoded
        // using the in JVM default character encoding but we also try the console's
        // encoding just in case.
        return getPasswords(encodedPwd, Charset.defaultCharset(), CONSOLE_CHARSET);
      }
    } else if (spec.startsWith("file:")) {
      String name = spec.substring("file:".length());
      File file = new File(name).getCanonicalFile();
      InputStream in = mFileInputStreams.get(file);
      if (in == null) {
        in = new FileInputStream(file);
        mFileInputStreams.put(file, in);
      }
      byte[] encodedPwd = readEncodedPassword(in);
      if (encodedPwd.length == 0) {
        throw new IOException("Failed to read " + description + " : end of file reached in " + file);
      }

View on GitHub (pinned to e4df245d82)