Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.6.0
-
None
Description
The SFTP client fails to retrieve a binary file from an SFTP server using the InputStream returned by the SftpClient.read (String) method.
In my case the binary file was actually a gzipped XML file. So I wrapped the returned InputStream in a java.util.zip.GZIPInputStream object. When reading from the stream I received an IOException with following message:
"org.apache.sshd.client.subsystem.sftp.SftpInputStreamWithChannel.read() returned value out of range -1..255: -117".
I think that this method violates the contract given in java.io.InputStream: "The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned."
After I patched line 130 in SftpInputStreamWithChannel.java to
return bb[0] & 0xFF;
retrieving the file seemed to have worked fine.