An edited version of the java code:
FileSystemOptions opts = new FileSystemOptions();
DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth);
// fileToMonitor is the FTP folder.
LOG.debug("Trying to resolve file " + fileToMonitor + "...");
FileObject fo = fileSystemManager.resolveFile(fileToMonitor, opts);
LOG.debug("File resolved, attempting to add to DefaultFileMonitor...");
DefaultFileMonitor monitor = createFileMonitor(processor);
// This line causes PORT and LIST commnads to be sent to the FTP server
monitor.addFile(fo);
LOG.debug("File successfully, added to DefaultFileMonitor");
I monitored the network traffic and it seems that when the FTP location is added to the monitor, it sends PORT and LIST commands to two folders on the server. The problem is that it keeps doing it (presumably till it runs out of client ports to call from?.
Here's an excerpt of the FTP network traffic:
50 0.312500 {TCP:2, IPv4:0} FTP FTP:Request from Port 12620,'PORT xxx,xxx,xxx,xxx,49,114'
51 0.312500 {TCP:2, IPv4:0} FTP FTP:Response to Port 12620, '200 PORT command successful.'
52 0.312500 {TCP:2, IPv4:0} FTP FTP:Request from Port 12620,'LIST tmp/dump'
<snipped>
270 1.750000 {TCP:2, IPv4:0} FTP FTP:Request from Port 12620,'PORT xxx,xxx,xxx,xxx,49,115'
271 1.750000 {TCP:2, IPv4:0} FTP FTP:Response to Port 12620, '200 PORT command successful.'
272 1.750000 {TCP:2, IPv4:0} FTP FTP:Request from Port 12620,'LIST tmp'
<snipped>
343 2.296875 {TCP:2, IPv4:0} FTP FTP:Request from Port 12620,'PORT xxx,xxx,xxx,xxx,49,116'
344 2.312500 {TCP:2, IPv4:0} FTP FTP:Response to Port 12620, '200 PORT command successful.'
345 2.312500 {TCP:2, IPv4:0} FTP FTP:Request from Port 12620,'LIST tmp/dump'
<snipped>
560 3.687500 {TCP:2, IPv4:0} FTP FTP:Response to Port 12620, '226 Transfer complete.'
566 4.031250 {TCP:2, IPv4:0} FTP FTP:Request from Port 12620,'PORT xxx,xxx,xxx,xxx,49,118'
567 4.031250 {TCP:2, IPv4:0} FTP FTP:Response to Port 12620, '200 PORT command successful.'
568 4.031250 {TCP:2, IPv4:0} FTP FTP:Request from Port 12620,'LIST tmp'
<repeat>
The part is the response from the LIST command. Note that the commands are repeated for the same folders but the port changes each time. This does not occur when there are no files at those locations.
What causes this behaviour and how can I change it so that only sends retrieves the listing once?
Edit: I've narrowed down the problem to the getChildren() method on the FileObject.
This is the only internet reference I could find: http://mail-archives.apache.org/mod_mbox/commons-user/201005.mbox/%[email protected]%3E