Hi,

I asked about this a little while ago - when you resolve a file for a SFTP url, the SFTP file system maintains the session until the file manager is closed - the solution you propsed (see below) works well, but this will not work if I try to use this in a multi-threaded environment.

FileSystemOptions fso = new FileSystemOptions();
SftpFileSystemConfigBuilder.getInstance().setUserInfo(fso, new TrustEveryoneUserInfo());


FileObject inFile = fsManager.resolveFile("sftp://someurl";, fso);

// do something with the file

StandardFileSystemManager fsm = (StandardFileSystemManager) VFS.getManager();
fsm.close();


A step closer (if i understand the arch. correctly) would be to expose the close method (as available on the SFTPFileSystem class for example) in the FileSystem interface. This allow you to retrieve the file system for the file object being accessed and manually close it. It is not the ideal solution, but would free the jsch session being held in the background.

Does this have any side-effects i haven't thought about - one i can think of is (again) concurrent access to the same filesystem. So, maybe the file system could close itself only if there are no more references to files within it?

So, something like this:

FileSystemOptions fso = new FileSystemOptions();
SftpFileSystemConfigBuilder.getInstance().setUserInfo(fso, new TrustEveryoneUserInfo());


FileObject inFile = fsManager.resolveFile("sftp://someurl";, fso);

// do something with the file

fs = inFile.getFileSystem();
fs.close();

What are the general thoughts about this?

Regards,

Johan

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to