Apache VFS sftp- is getting multiple fileObjects creating multiple sessions or channels?

480 views Asked by At

Consider the following code:

FileSystemManager fsManager = VFS.getManager();
FileObject sftpDir = fsManager.resolveFile("sftp://username:password@host/pub/downloads/");
FileObject child1 =  sftpDir.getChild("child1.data");
FileObject child2 =  sftpDir.getChild("child2.data");
InputStream s1 = child1.getContent().getInputStream();
InputStream s2 = child2.getContent().getInputStream();

On the Jsch underlying level, were two separated sessions created, or one session and two channels?

1

There are 1 answers

1
Martin Prikryl On BEST ANSWER

Two/more channels in one session.

The getInputStream implementation calls SftpFileSystem.getChannel(), which creates new channel or reuses existing idle channel.