commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mario Ivankovits <>
Subject Re: [VFS] FileSystem close
Date Wed, 07 Jul 2004 20:20:12 GMT
I try to take another approach to solve this problem.

During adapting the test-cases to close() every single resolved file i 
came to the conclusion it is nearly impossible to do this for a whole 
And if it comes to swap a system from to VFS it is way too 
hard to correctly place every FileObject.close().
Sometimes VFS do itself resolv files and then it has to check the state 
and maybe (or maybe not) close it after use.
I found it is a really complicated (and error-prone) thing.

So i picked up the SoftRefFilesCache and adapted it slightly.

The idea behind is - as long as a FileObject is "strongly reachable" by 
the jvm there must be someone who is willing to access the file and thus 
it is not allowed to close the filesystem.
As soon as the last file of a certain filesystem is garbage-collected 
the filesystem can be (and will be) closed.

For sure - now you do not have that control over this release process, 
but it should work well.

One has simply to ensure to release all references (assign null to it if 
it is a global member) to make this work.

I would like to remove the useCount (freeUnusedResources) stuff from vfs 
again. Could you please try this in your environment.

Instantiate your vfs manager like this:

StandardFileSystemManager manager = new StandardFileSystemManager();
manager.setFilesCache(new SoftRefFilesCache());

and remove the call to freeUnusedResources - and - as long as you do not 
use any input/output stream - the FileObject.close() is also no longer 


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message