commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From srimant misra <>
Subject Is there a VFS API to manage connections to the underlying provider (at in interface level) e.g. in FileSystemManager interface
Date Tue, 27 Sep 2005 05:26:03 GMT
I am using the VFS API to connect to a SFTP server. Here's the code that accesses the server
   FileSystemManager fsManager = VFS.getManager();
   FileObject file = fsManager.resolveFile("sftp://Administrator:jupe1234@",
opts );
   FileContent fileContent = file.getContent();
   BufferedReader br = new BufferedReader(new InputStreamReader(fileContent.getInputStream()));
   String line = br.readLine();
   while(line != null)
    line = br.readLine();
   br = null;
   fileContent = null;
   file = null;

However, the main thread hangs when this is executed. Unless the Session object instance provided
by the SFTP provider (JCraft in this case) is disconnected, a thread blocking on a socket
read does not allow the main thread to exit.
Unless VFS provides an API at the interface level in order to access the provider instance,
it will not be possible to close the session. Though APIs are available, but we will probably
need it the FileSystemManager interface.
Here's the thread dump that I get when the above code is executed.
"DestroyJavaVM" prio=5 tid=0x00a61950 nid=0x33c waiting on condition [0..7fad8]
"org.apache.commons.vfs.cache.SoftRefFilesCache$SoftRefReleaseThread" daemon pri
o=5 tid=0x03054540 nid=0xb44 runnable [34cf000..34cfd68]
        at java.lang.Object.wait(Native Method)
        at java.lang.ref.ReferenceQueue.remove(Unknown Source)
        - locked <0x10543a68> (a java.lang.ref.ReferenceQueue$Lock)
        at org.apache.commons.vfs.cache.SoftRefFilesCache$SoftRefReleaseThread.r
"Connect thread session" prio=5 tid=0x02d16b78 nid=0x70c runnable [348
        at Method)
        at Source)
        at com.jcraft.jsch.IO.getByte(Unknown Source)
        at Source)
        at Source)
        at Source)
"Signal Dispatcher" daemon prio=10 tid=0x009badf8 nid=0xbc4 waiting on condition
"Finalizer" daemon prio=9 tid=0x009b83a0 nid=0xd64 in Object.wait() [2b5f000..2b
        at java.lang.Object.wait(Native Method)
        - waiting on <0x105001c8> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(Unknown Source)
        - locked <0x105001c8> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(Unknown Source)
        at java.lang.ref.Finalizer$ Source)
"Reference Handler" daemon prio=10 tid=0x009b7018 nid=0xf8 in Object.wait() [2b1
        at java.lang.Object.wait(Native Method)
        - waiting on <0x104ffee8> (a java.lang.ref.Reference$Lock)
        at java.lang.Object.wait(Unknown Source)
        at java.lang.ref.Reference$ Source)
        - locked <0x104ffee8> (a java.lang.ref.Reference$Lock)
"VM Thread" prio=5 tid=0x009f7650 nid=0xefc runnable
"VM Periodic Task Thread" prio=10 tid=0x00a11c58 nid=0x71c waiting on condition
"Suspend Checker Thread" prio=10 tid=0x009ba360 nid=0xbc0 runnable
Thanks in advance

Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message