commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rich...@rswheeldon.com
Subject [vfs] Deadlock
Date Wed, 02 Jul 2008 12:49:04 GMT

Hi,

I'm in the middle of righting a highly multi-threaded app which
uses VFS to write output to a configurable list of FTP servers
and local file systems

    String url = baseUrl + fname;
    OutputStream ftpOut = null;
    PrintStream docOut = null;
    try {
        log.debug("Uploading to '" + url + "'");
        FileObject dirObj = VFS.getManager().resolveFile(baseUrl); // <-- Line 80
        if (!dirObj.exists()) {
            dirObj.createFolder();
        }
        FileObject fileObj = dirObj.resolveFile(fname); // <-- Line 84
        ftpOut = fileObj.getContent().getOutputStream(); // <-- Line 86
        docOut = new PrintStream(ftpOut);
        docOut.print(content);
        log.info("Upload to '" + url + "' completed");
        uploaded = true;
    } catch(IOException ioe) {
        log.warn("Failure uploading to " + url, ioe);
    } finally {
        IOUtils.closeQuietly(docOut);
    }

This has been working nicely for a while, but has just produced the
following deadlock:

Found one Java-level deadlock:
=============================
"Thread-760":
  waiting to lock monitor 0xa805d0dc (object 0xad3dd040, a org.apache.commons.vfs.provider.ftp.FtpFileSystem),
  which is held by "Thread-716"
"Thread-716":
  waiting to lock monitor 0x084aa954 (object 0xad3dd588, a java.lang.Object),
  which is held by "Thread-720"
"Thread-720":
  waiting to lock monitor 0xa805d0dc (object 0xad3dd040, a org.apache.commons.vfs.provider.ftp.FtpFileSystem),
  which is held by "Thread-716"

Java stack information for the threads listed above:
===================================================
"Thread-760":
        at org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:267)
        - waiting to lock <0xad3dd040> (a org.apache.commons.vfs.provider.ftp.FtpFileSystem)
        at org.apache.commons.vfs.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:88)
        at org.apache.commons.vfs.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:62)
        at org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:641)
        at org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:602)
        at org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:570)
        at com.reuters.agency.tvdams.lisa.DocumentOutputCommand.internalExecute(DocumentOutputCommand.java:80)
        at lisa.server.core.command.type.LisaMessageCommand.internalExecute(LisaMessageCommand.java:108)
        at lisa.server.core.command.type.BaseLisaCommand.execute(BaseLisaCommand.java:139)
        at lisa.server.core.command.type.BaseLisaCommand.call(BaseLisaCommand.java:106)
        at EDU.oswego.cs.dl.util.concurrent.FutureResult$1.run(Unknown Source)
        at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
"Thread-716":
        at org.apache.commons.vfs.provider.ftp.FtpFileSystem.getClient(FtpFileSystem.java:106)
        - waiting to lock <0xad3dd588> (a java.lang.Object)
        at org.apache.commons.vfs.provider.ftp.FtpFileObject.doGetChildren(FtpFileObject.java:120)
        at org.apache.commons.vfs.provider.ftp.FtpFileObject.getChildFile(FtpFileObject.java:103)
        at org.apache.commons.vfs.provider.ftp.FtpFileObject.getInfo(FtpFileObject.java:181)
        at org.apache.commons.vfs.provider.ftp.FtpFileObject.refresh(FtpFileObject.java:208)
        at org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:319)
        - locked <0xad3dd040> (a org.apache.commons.vfs.provider.ftp.FtpFileSystem)
        at org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:267)
        - locked <0xad3dd040> (a org.apache.commons.vfs.provider.ftp.FtpFileSystem)
        at org.apache.commons.vfs.provider.AbstractFileObject.resolveFile(AbstractFileObject.java:670)
        at com.reuters.agency.tvdams.lisa.DocumentOutputCommand.internalExecute(DocumentOutputCommand.java:84)
        at lisa.server.core.command.type.LisaMessageCommand.internalExecute(LisaMessageCommand.java:108)
        at lisa.server.core.command.type.BaseLisaCommand.execute(BaseLisaCommand.java:139)
        at lisa.server.core.command.type.BaseLisaCommand.call(BaseLisaCommand.java:106)
        at EDU.oswego.cs.dl.util.concurrent.FutureResult$1.run(Unknown Source)
        at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
"Thread-720":
        at org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:267)
        - waiting to lock <0xad3dd040> (a org.apache.commons.vfs.provider.ftp.FtpFileSystem)
        at org.apache.commons.vfs.provider.AbstractFileSystem.getRoot(AbstractFileSystem.java:242)
        at org.apache.commons.vfs.provider.ftp.FtpFileSystem.getClient(FtpFileSystem.java:108)
        - locked <0xad3dd588> (a java.lang.Object)
        at org.apache.commons.vfs.provider.ftp.FtpFileObject.doGetOutputStream(FtpFileObject.java:490)
        at org.apache.commons.vfs.provider.AbstractFileObject.getOutputStream(AbstractFileObject.java:1219)
        at org.apache.commons.vfs.provider.DefaultFileContent.getOutputStream(DefaultFileContent.java:373)
        at org.apache.commons.vfs.provider.DefaultFileContent.getOutputStream(DefaultFileContent.java:356)
        at com.reuters.agency.tvdams.lisa.DocumentOutputCommand.internalExecute(DocumentOutputCommand.java:86)
        at lisa.server.core.command.type.LisaMessageCommand.internalExecute(LisaMessageCommand.java:108)
        at lisa.server.core.command.type.BaseLisaCommand.execute(BaseLisaCommand.java:139)
        at lisa.server.core.command.type.BaseLisaCommand.call(BaseLisaCommand.java:106)
        at EDU.oswego.cs.dl.util.concurrent.FutureResult$1.run(Unknown Source)
        at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)


This looks like a nasty bug to me but it's quite possible I'm doing something stupid. Any
ideas?

Richard

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


Mime
View raw message