jsch
jsch copied to clipboard
ArrayIndexOutOfBoundsException raised on sftp downloading
I use the following codes to start sftp downloading:
var remoteFile: InputStream? = null
remoteFile = channel?.get(
args["path"] as String,
ProgressMonitor(client.id, "DownloadProgress", eventSink)
)
val buffer = ByteArray(4096)
while (true) {
val count = remoteFile.read(buffer)
if (count == -1) {
break
}
outputStream.write(buffer, 0, count)
}
the following exception raised sometimes:
Exception java.lang.ArrayIndexOutOfBoundsException:
at java.lang.System.arraycopy
at com.jcraft.jsch.ChannelSftp$2.read (ChannelSftp.java:1359)
at java.io.InputStream.skip (InputStream.java:547)
at com.jcraft.jsch.ChannelSftp$2.read (ChannelSftp.java:1408)
at com.jcraft.jsch.ChannelSftp$2.read (ChannelSftp.java:1336)
The jsch version is 0.2.17.
Have you tried the latest release?
I noticed that some users encountered this error, but I haven't experienced it myself.
After reviewing the release logs, I found no relevant fixes, so I reported this bug.