title: Apache Commons VFS thread safety and resource management
body: <p>I'm looking into using <a href="http://commons.apache.org/proper/commons-vfs/">Apache Commons VFS</a> for a project that will need to transfer files between local server and remote servers via ftp, sftp and https.</p>
  
  <p>The standard usage examples are getting the FileSystemManager from a static method</p>
  
  <pre><code>FileSystemManager fsManager = VFS.getManager();
  </code></pre>
  
  <p>Is it safe to use the same FileSystemManager across multiple threads?</p>
  
  <p>And a second question is about properly releasing resources in a finally block: I find the following methods in the Javadoc API:</p>
  
  <ul>
  <li><a href="http://commons.apache.org/proper/commons-vfs/apidocs/org/apache/commons/vfs2/FileObject.html#close()">http://commons.apache.org/proper/commons-vfs/apidocs/org/apache/commons/vfs2/FileObject.html#close()</a></li>
  <li><a href="http://commons.apache.org/proper/commons-vfs/apidocs/org/apache/commons/vfs2/FileSystemManager.html#closeFileSystem(org.apache.commons.vfs2.FileSystem)">http://commons.apache.org/proper/commons-vfs/apidocs/org/apache/commons/vfs2/FileSystemManager.html#closeFileSystem(org.apache.commons.vfs2.FileSystem)</a></li>
  <li><a href="http://commons.apache.org/proper/commons-vfs/apidocs/org/apache/commons/vfs2/FilesCache.html#close()">http://commons.apache.org/proper/commons-vfs/apidocs/org/apache/commons/vfs2/FilesCache.html#close()</a></li>
  <li><a href="http://commons.apache.org/proper/commons-vfs/apidocs/org/apache/commons/vfs2/impl/DefaultFileSystemManager.html#close()">http://commons.apache.org/proper/commons-vfs/apidocs/org/apache/commons/vfs2/impl/DefaultFileSystemManager.html#close()</a></li>
  </ul>
  
  <p>But it's not clear to me which of these resources should typically be closed.</p>