Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
992 views
in Java FTP by (180 points)

The following code causes the thread to hang until a socket timeout occurs:

FileTransferClient ftpClient = ...create and connect... ;
try (InputStream is = ftpClient.downloadStream("does_not_exist");
      OutputStream os = new FileOutputStream(new File(localFileName));) {
            IOUtils.copy(is, os);
}

The effect is that IOUtils.copy() fails with an IOException ("com.enterprisedt.net.ftp.FTPException: does_not_exist: No such file or directory") and the try-with-resources subsequently calls FTPInputStream.close() on "is". The FTPInputStream.close() hangs until the socket timeout (default 60s) occurs.

This problem is reproducable with a "FtpTester" tool I built (and I can provide, if desired). The output of the FtpTester tool is here: http://pastebin.com/srPgkJRY - note the timestamps [16/06/02 15:04:57.772 CEST] and [16/06/02 15:05:57.775 CEST] that are 60 seconds apart (socket timeout).

The image "stacktrace.png" shows where the thread hangs after FTPInputStream.close() is called: stacktrace

by (162k points)
moved by
Sorry for the late reply - we only just noticed this question.

That's a weird issue, because the first thing downloadStream does is to test if the file exists. If it does not, an exception is thrown, so it should never get to IOUtils.copy(is, os).

If you have a DEBUG level log file that might tell us more.
by (180 points)
You can fing the DEBUG log here: http://pastebin.com/srPgkJRY
by (162k points)
Please email support at enterprisedt dot com and we'll send you the latest version to try - it looks like it is fixed there (unreleased, we'll release it soon).
by (180 points)
I downloaded the latest version ("edtftpj-2.5.0.zip") and re-built my FTP tester tool with that. The issue is indeed fixed with 2.5.0. Thank you very much!

Here's the output of my FTP tester tool with both versions: http://pastebin.com/Qe4UYVJ4

Please log in or register to answer this question.

Categories

...