-
Notifications
You must be signed in to change notification settings - Fork 175
Open
Description
Hello,
I'm using jsch 2.27.2 to download files from an SFTP server.
Today the server seems a lot slower than usual and I'm getting this error:
Caused by: java.io.IOException: inputstream is closed
at com.jcraft.jsch.ChannelSftp.fill(ChannelSftp.java:2872)
at com.jcraft.jsch.ChannelSftp.header(ChannelSftp.java:2898)
at com.jcraft.jsch.ChannelSftp.start(ChannelSftp.java:254)
It seems to me that header() attemps to read 9 bytes from the input stream, but does not get anything because the (super slow) server has not started replying.
I tried adding a delay Thread.sleep(Duration.ofMinutes(1)); before that line:
| header = header(buf, header); |
The workaround seems to work albeit obviously slowing things down.
Would you agree that this seems like a bug?
IMO the fill() method (or its caller) should somehow loop when it does not read enough data.
The commented out code seems to indicate that this was the intent at some point:
jsch/src/main/java/com/jcraft/jsch/ChannelSftp.java
Lines 2862 to 2879 in 90a7d9e
| private int fill(byte[] buf, int s, int len) throws IOException { | |
| int i = 0; | |
| int foo = s; | |
| while (len > 0) { | |
| i = io_in.read(buf, s, len); | |
| if (i <= 0) { | |
| throw new IOException("inputstream is closed"); | |
| // return (s-foo)==0 ? i : s-foo; | |
| } | |
| s += i; | |
| len -= i; | |
| } | |
| return s - foo; | |
| } | |
| private void skip(long foo) throws IOException { | |
| while (foo > 0) { | |
| long bar = io_in.skip(foo); |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels