commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From srimant misra <srimantmi...@yahoo.com>
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
Hi, 
 
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@127.0.0.1/home/Administrator/Mydoc.txt",
opts );
   FileContent fileContent = file.getContent();
   BufferedReader br = new BufferedReader(new InputStreamReader(fileContent.getInputStream()));
   String line = br.readLine();
   while(line != null)
   {
    System.out.println(line);
    line = br.readLine();
   }
   br.close();
   br = null;
   fileContent = null;
   file = null;
   System.out.println("Finito");

   
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
un(SoftRefFilesCache.java:76)
"Connect thread 127.0.0.1 session" prio=5 tid=0x02d16b78 nid=0x70c runnable [348
f000..348fd68]
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(Unknown Source)
        at com.jcraft.jsch.IO.getByte(Unknown Source)
        at com.jcraft.jsch.Session.read(Unknown Source)
        at com.jcraft.jsch.Session.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
"Signal Dispatcher" daemon prio=10 tid=0x009badf8 nid=0xbc4 waiting on condition
 [0..0]
"Finalizer" daemon prio=9 tid=0x009b83a0 nid=0xd64 in Object.wait() [2b5f000..2b
5fd68]
        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$FinalizerThread.run(Unknown Source)
"Reference Handler" daemon prio=10 tid=0x009b7018 nid=0xf8 in Object.wait() [2b1
f000..2b1fd68]
        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$ReferenceHandler.run(Unknown 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
-Srimant


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message