commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filip Defoort <filip...@cirquedigital.com>
Subject [VFS] Bug in FileObject.createFile() on local FS
Date Thu, 20 Jul 2006 21:09:07 GMT
Hi VFS,

I've found a bug in the FileObject.createFile(): the docs state:

     * Creates this file, if it does not exist.  Also creates any ancestor
     * folders which do not exist.  This method does nothing if the file
     * already exists and is a file.
     *

But that's not what AbstractFileObject does; it *does* destroy
the file when it already exists.

The culprit is AbstractFileObject:

                getOutputStream().close();

The file should be created in append mode instead....

Testing is pretty straightforward, just run something like:

            StandardFileSystemManager fileSystemManager
                 = new StandardFileSystemManager();

            fileSystemManager.setCacheStrategy(CacheStrategy.ON_RESOLVE);
            fileSystemManager.init();

            FileSystemOptions fileoptions = new FileSystemOptions();
            FileObject root = fileSystemManager.resolveFile("/tmp/", 
fileoptions);

            FileObject fo = root.resolveFile("test.txt");

            fo.createFile();

on a file that already exists and has contents and you'll see the problem...

It'd be fabulous is someone could patch this...

Cheers,
- Filip

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message