[
https://issues.apache.org/jira/browse/VFS-544?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14207803#comment-14207803
]
Bernd Eckenfels edited comment on VFS-544 at 11/12/14 8:49 AM:
---------------------------------------------------------------
Given the fact we cannot register a VirtualFileProvider by scheme (and it does
not implement AbstractFileProvider), I guess it is best to hardcode the closing
of those objects in _closeFileSystem:
{code}
public void _closeFileSystem(final FileSystem filesystem)
{
final FileProvider provider =
providers.get(filesystem.getRootName().getScheme());
if (provider != null)
{
((AbstractFileProvider) provider).closeFileSystem(filesystem);
}
else if (filesystem instanceof VirtualFileSystem)
{
vfsProvider.closeFileSystem(filesystem);
}
}
{code}
And also making vfsProvider not final, so it can be constructed in init() and
destroyed in close(). Will append a patch.
was (Author: b.eckenfels):
Given the fact we cannot register a VirtualFileProvider by scheme (and it does
not implement AbstractFileProvider), I guess it is best to hardcode the closing
of those objects in _closeFileSystem:
<pre> public void _closeFileSystem(final FileSystem filesystem)
{
if (filesystem instanceof VirtualFileSystem)
{
vfsProvider.closeFileSystem(filesystem);
return;
}
final FileProvider provider =
providers.get(filesystem.getRootName().getScheme());
if (provider != null)
{
((AbstractFileProvider) provider).closeFileSystem(filesystem);
}
}
</pre>
And also making vfsProvider not final, so it can be constructed in init() and
destroyed in close(). Will append a patch.
> VirtualFileSystems leak
> -----------------------
>
> Key: VFS-544
> URL: https://issues.apache.org/jira/browse/VFS-544
> Project: Commons VFS
> Issue Type: Bug
> Affects Versions: 2.0
> Reporter: Bernd Eckenfels
> Assignee: Bernd Eckenfels
> Labels: leak
> Fix For: 2.1
>
>
> When creating a org.apache.commons.vfs2.impl.VirtualFileSystem by
> org.apache.commons.vfs2.impl.VirtualFileProvider it is tracked as a
> component. But since VirtualFileProvider is not an AbstractFileProvider and
> not registered in providers it will never be closed by
> org.apache.commons.vfs2.impl.DefaultFileSystemManager._closeFileSystem(FileSystem).
> Also the final instance of VirtualFileProvider does not get closed when the
> DefaultFileSystemManager gets closed.
> VirtualFileSystem itself does not have critical resources, but its
> DelegatedFiles are cached so there should be a way to close them.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)