In my code I am trying to keep the Jsch session active cause I expect many interactions with the server will happen. And the logic is:
- One thread will open channel on the session to check if a file exists
- Another thread try to open channel on the same session to send a file to the server
However I found if #1 give me a "file not found", #2 will fail with the same exception at here:
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_HANDLE){
throw new SftpException(SSH_FX_FAILURE, "invalid type="+type);
}
if(type==SSH_FXP_STATUS){
int i=buf.getInt();
>>>> throwStatusError(buf, i);
}
byte[] handle=buf.getString(); // handle
byte[] data=null;
So the question is why the new channel got the same error with previous channel even before I put a single byte to the channel?