Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 59155 invoked from network); 1 Sep 2005 16:10:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 1 Sep 2005 16:10:26 -0000 Received: (qmail 19200 invoked by uid 500); 1 Sep 2005 16:10:18 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 19153 invoked by uid 500); 1 Sep 2005 16:10:16 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 19140 invoked by uid 99); 1 Sep 2005 16:10:15 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Sep 2005 09:10:15 -0700 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=HTML_50_60,HTML_MESSAGE,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of jsurf@gmx.de designates 213.165.64.20 as permitted sender) Received: from [213.165.64.20] (HELO mail.gmx.net) (213.165.64.20) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 01 Sep 2005 09:10:30 -0700 Received: (qmail invoked by alias); 01 Sep 2005 16:10:12 -0000 Received: from dialer-190-190.kielnet.net (EHLO jviebigXP) [82.97.190.190] by mail.gmx.net (mp016) with SMTP; 01 Sep 2005 18:10:12 +0200 X-Authenticated: #1112833 Message-ID: <019b01c5af0f$9a4328b0$fe78a8c0@jviebigXP> From: "Jens Viebig" To: Subject: [VFS] FTPClientWrapper Broken Pipe Date: Thu, 1 Sep 2005 18:09:59 +0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0198_01C5AF20.5D6A50B0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Y-GMX-Trusted: 0 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_NextPart_000_0198_01C5AF20.5D6A50B0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello List, i'm using VFS to regulary check some files on an FTP server. This works = fine for a long time, but after a while the check crashes with the = following stacktrace: org.apache.commons.vfs.FileSystemException: Could not determine the type = of file ftp://user:password@myserver.com/myfile.txt. at = org.apache.commons.vfs.provider.AbstractFileObject.attach()V(Optimized = Method) at = org.apache.commons.vfs.provider.AbstractFileObject.exists()Z(AbstractFile= Object.java:391) at my.class.Something.toDo(Unknown Source) at java.lang.Thread.run()V(Unknown Source) at = java.lang.Thread.startThreadFromVM(Ljava.lang.Thread;)V(Unknown Source) Caused by: java.net.SocketException: Broken pipe at jrockit.net.SocketNativeIO.write(IIIZ)I(Unknown Source) at jrockit.net.SocketNativeIO.write(III)I(Unknown Source) at = jrockit.io.NativeIO.write(Ljava.io.FileDescriptor;II)I(Optimized Method) at java.net.AbstractSocketImpl$2.write(II)V(Optimized Method) at jrockit.io.NativeIOOutputStream.write([BII)V(Optimized = Method) at java.io.BufferedOutputStream.flushBuffer()V(Optimized Method) at java.io.BufferedOutputStream.write(I)V(Optimized Method) at org.apache.commons.net.telnet.Telnet._sendByte(I)V(Optimized = Method) at = org.apache.commons.net.telnet.TelnetOutputStream.write(I)V(Optimized = Method) at = org.apache.commons.net.io.ToNetASCIIOutputStream.write([BII)V(Optimized = Method) at = sun.nio.cs.StreamEncoder$CharsetSE.writeBytes()V(StreamEncoder.java:325) at sun.nio.cs.StreamEncoder$CharsetSE.implWrite([CII)V(Optimized = Method) at sun.nio.cs.StreamEncoder.write([CII)V(StreamEncoder.java:136) at = java.io.OutputStreamWriter.write([CII)V(OutputStreamWriter.java:191) at = java.io.BufferedWriter.flushBuffer()V(BufferedWriter.java:107) at java.io.BufferedWriter.flush()V(BufferedWriter.java:228) at = org.apache.commons.net.ftp.FTP.sendCommand(Ljava.lang.String;Ljava.lang.S= tring;)I(Optimized Method) at = org.apache.commons.net.ftp.FTP.sendCommand(ILjava.lang.String;)I(Optimize= d Method) at = org.apache.commons.net.ftp.FTP.port(Ljava.net.InetAddress;I)I(Optimized = Method) at = org.apache.commons.vfs.provider.ftp.FTPClientWrapper.listFiles(Ljava.lang= .String;Ljava.lang.String;)[Lorg.apache.commons.net.ftp.FTPFile;(Optimize= d Method) at = org.apache.commons.vfs.provider.ftp.FtpFileObject.doGetChildren()V(Optimi= zed Method) at = org.apache.commons.vfs.provider.ftp.FtpFileObject.getChildFile(Ljava.lang= .String;Z)Lorg.apache.commons.net.ftp.FTPFile;(Optimized Method) at = org.apache.commons.vfs.provider.ftp.FtpFileObject.getInfo(Z)V(Optimized = Method) at = org.apache.commons.vfs.provider.ftp.FtpFileObject.doAttach()V(Optimized = Method) ... 6 more When it comes to that error, the filesystem provider never recovers from = that crash and all actions on files on the same ftp server fail. The ftp = server works fine, i can connect fine from the commandline. it seems = that the VFS ftp provider tries to reuse that old damaged connection, i = don't see a new attempt to login in my ftp server log. There is no = connection from VFS to the ftp server. I looked in the source code of FTPClientWrapper, and tracked the error = down to the listFiles function: ... public FTPFile[] listFiles(String key, String relPath) throws = IOException { try { return getFtpClient().listFiles(key, relPath); } catch (FTPConnectionClosedException e) { disconnect(); return getFtpClient().listFiles(key, relPath); } } ... the FTPClient of commons.net throws FTPConnectionClosedException and = IOException. if a FTPConnectionClosedException is thrown everything is = fine, the old connection is closed and a new one is created. If a more = general IOException is thrown the connection is not closed and not set = to null, so the FTPClientWrapper tries to use it again. Normally = isConnected() should fail then, but it seems that it still returns true = und is a weak test. I suggest that the connection should also be = disconnected and set to null on more general errors, if there is an = IOException there is a big chance that the connection is not usable = anymore. Maybe like this: public FTPFile[] listFiles(String key, String relPath) throws = IOException { try { return getFtpClient().listFiles(key, relPath); } catch (FTPConnectionClosedException e) { disconnect(); return getFtpClient().listFiles(key, relPath); } catch (IOException ie) { disconnect(); throw ie; } } This fix should be applied to all functions in FTPClientWrapper Maybe you have a better approach on fixing this issue ? ------=_NextPart_000_0198_01C5AF20.5D6A50B0--