commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ibrahim Hasbini <hasb...@gmail.com>
Subject [vfs] FileSystemException: Could not create FTP directory when attempting to create a directory
Date Thu, 12 Jan 2012 09:25:54 GMT
Hello,

I've been facing an issue where simultaneous threads may be creating
the same directory (using VFS + FTP storage) and failing with the
exception shown below.
I thought I'd post about this issue to see if anyone faced a similar
issue and could help.

When I first encountered the exception I thought I'd catch it and
check to see if the directory being created already existed (i.e.
possibly another thread created it), and if it did then ignore the
exception.
However even with that check, the exception is occurring intermittently.

I have also looked at the code of
org.apache.commons.vfs.provider.ftp.FtpFileObject.doCreateFolder() and
it seems that the result code returned by the FTP server is hidden,
because the call to FtpClient.makeDirectory() just returns a boolean
to indicate success or failure.

Here's my code that calls VFS's createFolder():

    private void createFolderInternal(FileObject storageFileObject)
throws Exception {
        if (storageFileObject.getParent() != null) {
            createFolderInternal(storageFileObject.getParent());
        }
        try {
            storageFileObject.createFolder();
        } catch (FileSystemException fsex) {
            if (storageFileObject.getParent() != null) {
                storageFileObject.getParent().refresh();
            }
            storageFileObject.refresh();
            if (!storageFileObject.exists()) {
                throw fsex;
            }
        }
    }


below is the exception:

org.apache.commons.vfs.FileSystemException: Could not create folder
"ftp://ftpserver/storage1/logs/1788251-120106-1831-19812".
    at org.apache.commons.vfs.provider.AbstractFileObject.createFolder(AbstractFileObject.java:969)
    at m.a.c.s.vfs.VFSStorageFile.createFolderInternal(VFSStorageFile.java:173)
    at m.a.c.s.vfs.VFSStorageFile.createFolder(VFSStorageFile.java:164)
    at m.a.c.s.StorageClient.store(StorageClient.java:103)
    at m.a.c.b.DefaultBuilder.storeOutputInternal(DefaultBuilder.java:628)
    at m.a.c.b.DefaultBuilder.storeOutput(DefaultBuilder.java:246)
    at sun.reflect.GeneratedMethodAccessor340.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:39)
    at java.lang.reflect.Method.invoke(Method.java:612)
    at m.a.c.a.AsyncAgent$AsyncAgentRunnable.run(AsyncAgent.java:164)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:454)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:316)
    at java.util.concurrent.FutureTask.run(FutureTask.java:151)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:898)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:920)
    at java.lang.Thread.run(Thread.java:735)
Caused by: org.apache.commons.vfs.FileSystemException: Could not
create folder "ftp://ftpserver/builds/storages/storage1/logs/1788251-120106-1831-19812".
    at org.apache.commons.vfs.provider.AbstractFileObject.createFolder(AbstractFileObject.java:969)
    at org.apache.commons.vfs.provider.DelegateFileObject.doCreateFolder(DelegateFileObject.java:232)
    at org.apache.commons.vfs.provider.AbstractFileObject.createFolder(AbstractFileObject.java:958)
    ... 15 more
Caused by: org.apache.commons.vfs.FileSystemException: Could not
create FTP directory
"ftp://ftpserver/builds/storages/storage1/logs/1788251-120106-1831-19812".
    at org.apache.commons.vfs.provider.ftp.FtpFileObject.doCreateFolder(FtpFileObject.java:532)
    at org.apache.commons.vfs.provider.AbstractFileObject.createFolder(AbstractFileObject.java:958)
    ... 17 more


Thank you,
Ibrahim Hasbini

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


Mime
View raw message