This works fine:
AsyncFileTransferClient session = new AsyncFileTransferClient (1, 4);
session.setRemoteHost ("localhost");
session.setUserName ("anonymous");
session.setPassword ("test");
session.connect ();
String remoteDirectory = "ftptests";
session.changeDirectory (remoteDirectory);
String filename = "101-put-ok.xml";
// Strategy 1: download to byte array (works fine)
byte[] localFile = session.downloadByteArray (filename);
long byteCount = localFile.length;
session.disconnect ();
assertEquals ("1 localFile length", 240, byteCount);
but this doesn't free the connection and doesn't terminate:
AsyncFileTransferClient session = new AsyncFileTransferClient (1, 4);
session.setRemoteHost ("localhost");
session.setUserName ("anonymous");
session.setPassword ("test");
session.connect ();
String remoteDirectory = "ftptests";
session.changeDirectory (remoteDirectory);
String filename = "101-put-ok.xml";
// Strategy 2: download to stream
FileTransferInputStream localFile = session.downloadStream (filename);
byte[] buffer = new byte[2000];
long byteCount = localFile.read (buffer, 0, 2000);
long end = localFile.read (buffer);
localFile.close ();
session.disconnect ();
assertEquals ("1 localFile length", 240, byteCount);
Fragment of log for strategy 1:
10:41:10,451 DEBUG [main] edt.AsyncResult - waitTillComplete() called: com.enterprisedt.net.ftp.async.DownloadByteArrayResult@7ffc6e42
10:41:10,451 DEBUG [main] edt.AsyncResult - Waiting until operation complete - com.enterprisedt.net.ftp.async.DownloadByteArrayResult
10:41:10,451 INFO [FTPThread_edt_4] edt.FTPTaskProcessor - Processing task 3:Download[101-put-ok.xml=> byteArray]
10:41:10,451 DEBUG [FTPThread_edt_4] edt.FTPConnectionPool - Waiting for a free connection ...
10:41:10,467 DEBUG [FTPThread_edt_4] edt.FTPConnectionPool - Connection now free!
10:41:10,467 DEBUG [FTPThread_edt_4] edt.FTPConnectionPool - Got a free connection: FTPConnection #1(0 left)
10:41:10,467 DEBUG [FTPThread_edt_4] edt.AsyncResult - notifyComplete() called: com.enterprisedt.net.ftp.async.DownloadByteArrayResult@7ffc6e42
10:41:10,467 DEBUG [FTPThread_edt_4] edt.AsyncResult - waitTillComplete() called: com.enterprisedt.net.ftp.async.DownloadByteArrayResult@7ffc6e42
10:41:10,467 DEBUG [main] edt.AsyncResult - waitTillComplete() exit: com.enterprisedt.net.ftp.async.DownloadByteArrayResult@7ffc6e42
10:41:10,467 DEBUG [FTPThread_edt_4] edt.AsyncResult - waitTillComplete() exit: com.enterprisedt.net.ftp.async.DownloadByteArrayResult@7ffc6e42
10:41:10,467 INFO [FTPThread_edt_4] edt.FTPTaskProcessor - Processed task 3:Download[101-put-ok.xml=> byteArray]
10:41:10,467 INFO [FTPThread_edt_4] edt.FTPTaskProcessor - Freed connection for task 3
10:41:10,467 INFO [FTPThread_edt_4] edt.FTPTaskProcessor - Task 3 complete (FTPThread[FTPThread_edt_4])
Fragment of log for strategy 2:
10:43:40,916 INFO [FTPThread_edt_4] edt.FTPTaskProcessor - Processing task 3:Download[101-put-ok.xml=>stream]
10:43:40,916 DEBUG [FTPThread_edt_4] edt.FTPConnectionPool - Waiting for a free connection ...
10:43:40,932 DEBUG [FTPThread_edt_4] edt.FTPConnectionPool - Connection now free!
10:43:40,932 DEBUG [FTPThread_edt_4] edt.FTPConnectionPool - Got a free connection: FTPConnection #1(0 left)
Environment:
edtftpj-pro version 4.5.0
jdk 1.6.0-43
Windows 7
FileZilla server
I'll supply exhaustive diagnostic information if necessary, but perhaps I'm missing something obvious.
Suggestions welcome
Simon