Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jsch stuck on cd throwing error code 4 without any message in integration test with testcontainer #792

Open
Cemtk6246 opened this issue Mar 14, 2025 · 0 comments

Comments

@Cemtk6246
Copy link

Hello,
i have a integration test with a custom sftp testcontainer. In this integration test i can connect to the container and the first test runs threw without any issues. But all other test fail with the exception code 4. When i debug the connection is still established i can use pwd() but the commands cd() and ls() are not working. After investigating I saw that this method causes the issue:

private byte[] _realpath(String path) throws SftpException, IOException, Exception {
    sendREALPATH(Util.str2byte(path, fEncoding));

    Header header = new Header();
    header = header(buf, header);
    int length = header.length;
    int type = header.type;

    fill(buf, length);

    if (type != SSH_FXP_STATUS && type != SSH_FXP_NAME) {
      throw new SftpException(SSH_FX_FAILURE, "");
    }
    int i;
    if (type == SSH_FXP_STATUS) {
      i = buf.getInt();
      throwStatusError(buf, i);
    }
    i = buf.getInt(); // count

    byte[] str = null;
    while (i-- > 0) {
      str = buf.getString(); // absolute path;
      if (server_version <= 3) {
        byte[] lname = buf.getString(); // long filename
      }
      SftpATTRS attr = SftpATTRS.getATTR(buf); // dummy attribute
    }
    return str;
  }

did anyone find a solution to this problem except of restarting the container?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant