Hello 👋
I'm using jsch to download files via SFTP using the get(String) function that returns an InputStream. Taking a look on the code, I discovered that if the server returns a non-EOF status code during a read, we will throw a generic IOException with the message "error", which makes it very hard to debug:
com.jcraft.jsch.ChannelSftp$2 read "ChannelSftp.java" 1427
java.io.InputStream readNBytes "InputStream.java" 412
java.io.InputStream readAllBytes "InputStream.java" 349
(Full stack trace from our Clojure application below.)
Looking at the source code, I discovered that there used to be a call to throwStatusError, which would return a richer exception data including the status enum, but this is commented out and taking a look at past commits I couldn't find the reason why.
|
if (type == SSH_FXP_STATUS) { |
|
fill(buf, rest_length); |
|
int i = buf.getInt(); |
|
rest_length = 0; |
|
if (i == SSH_FX_EOF) { |
|
close(); |
|
return -1; |
|
} |
|
// throwStatusError(buf, i); |
|
throw new IOException("error"); |
|
} |
I am currently debugging some intermitend server exceptios on my application, and having this code commented makes it impossible to know whether the failure was SSH_FX_NO_SUCH_FILE, SSH_FX_PERMISSION_DENIED, SSH_FX_FAILURE, or something else.
Do you know if this commented code is intentional, or is it just a behavior inherited from the original jcraft/jsch code?
Full stack trace (Clojure)
[com.jcraft.jsch.ChannelSftp$2 read "ChannelSftp.java" 1427]
[java.io.InputStream readNBytes "InputStream.java" 412]
[java.io.InputStream readAllBytes "InputStream.java" 349]
[common_ftp.components.sftp$fn__21345$get_file__21350$fn__21351$fn__21356 invoke "sftp.clj" 189]
[common_ftp.components.sftp$ignoring_missing_file invokeStatic "sftp.clj" 162]
[common_ftp.components.sftp$ignoring_missing_file invoke "sftp.clj" 157]
[common_ftp.components.sftp$fn__21345$get_file__21350$fn__21351 invoke "sftp.clj" 186]
[common_ftp.components.sftp$fn__21345$get_file__21350 invoke "sftp.clj" 182]
...
Exception cause: "error"
Hello 👋
I'm using jsch to download files via SFTP using the
get(String)function that returns anInputStream. Taking a look on the code, I discovered that if the server returns a non-EOF status code during a read, we will throw a genericIOExceptionwith the message"error", which makes it very hard to debug:(Full stack trace from our Clojure application below.)
Looking at the source code, I discovered that there used to be a call to
throwStatusError, which would return a richer exception data including the status enum, but this is commented out and taking a look at past commits I couldn't find the reason why.jsch/src/main/java/com/jcraft/jsch/ChannelSftp.java
Lines 1418 to 1428 in 90a7d9e
I am currently debugging some intermitend server exceptios on my application, and having this code commented makes it impossible to know whether the failure was
SSH_FX_NO_SUCH_FILE,SSH_FX_PERMISSION_DENIED,SSH_FX_FAILURE, or something else.Do you know if this commented code is intentional, or is it just a behavior inherited from the original
jcraft/jschcode?Full stack trace (Clojure)
Exception cause:
"error"