You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Dmitry (Jira)" <ji...@apache.org> on 2022/10/26 21:57:00 UTC
[jira] [Created] (VFS-826) SFTP file get content issue for some servers
Dmitry created VFS-826:
--------------------------
Summary: SFTP file get content issue for some servers
Key: VFS-826
URL: https://issues.apache.org/jira/browse/VFS-826
Project: Commons VFS
Issue Type: Bug
Affects Versions: 2.9.0
Reporter: Dmitry
Some SFTP servers does not allow multiple channels open at same time,
but SftpFileObject always open two if no hacks applied - at first just creates channel, then creates new channel to fetch type.
Possible solution is to move file type check on top, so underlying code of getType will 'park' channel and then it will be reused.
{code:java}
protected InputStream doGetInputStream(int bufferSize) throws Exception {
synchronized((SftpFileSystem)this.getAbstractFileSystem()) {
ChannelSftp channel = ((SftpFileSystem)this.getAbstractFileSystem()).getChannel();
InputStream inputStream;
try {
if (!this.getType().hasContent()) {
throw new FileSystemException("vfs.provider/read-not-file.error", this.getName());
}
inputStream = channel.get(this.relPath);
} catch (SftpException var7) {
if (var7.id == 2) {
throw new FileNotFoundException(this.getName());
}
throw new FileSystemException(var7);
}
return new SftpInputStream(channel, inputStream, bufferSize);
}
} {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)