Author: imario
Date: Tue Mar 28 22:29:53 2006
New Revision: 389691

URL: http://svn.apache.org/viewcvs?rev=389691&view=rev
Log:
retry sftp stat if it failed

Modified:
    
jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java

Modified: 
jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java?rev=389691&r1=389690&r2=389691&view=diff
==============================================================================
--- 
jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java
 (original)
+++ 
jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java
 Tue Mar 28 22:29:53 2006
@@ -106,22 +106,40 @@
         */
        private void statSelf() throws Exception
        {
-               final ChannelSftp channel = fileSystem.getChannel();
+               ChannelSftp channel = fileSystem.getChannel();
                try
                {
                        setStat(channel.stat(relPath));
                }
                catch (final SftpException e)
                {
-                       // TODO - not strictly true, but jsch 0.1.2 does not 
give us
-                       // enough info in the exception. Should be using:
-                       // if ( e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE )
-                       // However, sometimes the exception has the correct id, 
and
-                       // sometimes
-                       // it does not. Need to look into why.
-
-                       // Does not exist
-                       attrs = null;
+                       try
+                       {
+                               // maybe the channel has some problems, so 
recreate the channel and retry
+                               if (e.id != ChannelSftp.SSH_FX_NO_SUCH_FILE)
+                               {
+                                       channel.disconnect();
+                                       channel = fileSystem.getChannel();
+                                       setStat(channel.stat(relPath));
+                               }
+                               else
+                               {
+                                       // Really does not exist
+                                       attrs = null;
+                               }
+                       }
+                       catch (final SftpException e2)
+                       {
+                               // TODO - not strictly true, but jsch 0.1.2 
does not give us
+                               // enough info in the exception. Should be 
using:
+                               // if ( e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE 
)
+                               // However, sometimes the exception has the 
correct id, and
+                               // sometimes
+                               // it does not. Need to look into why.
+       
+                               // Does not exist
+                               attrs = null;
+                       }
                }
                finally
                {



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to