的編輯java代碼的版本:爲什麼DefaultFileMonitor會將文件保存在我的FTP位置中的一個循環中?
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");
我監視網絡流量,似乎當FTP位置被添加到顯示器,它發送PORT和LIST命令到服務器上的兩個文件夾。問題是,它一直這樣做(據推測,直到用完客戶端端口從?
撥打這裏的FTP網絡流量的摘錄:
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>
的部分是從LIST響應命令,請注意,對於相同的文件夾重複執行這些命令,但端口每次都會發生更改,但在這些位置沒有文件時不會發生這種情況
導致此行爲的原因以及如何更改它以便只發送檢索上市一次?
編輯: 我已經將問題縮小到FileObject上的getChildren()方法。
這是唯一的互聯網參考我能找到的: http://mail-archives.apache.org/mod_mbox/commons-user/201005.mbox/%[email protected]%3E