Skip to content

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

@Cemtk6246

Description

@Cemtk6246

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions