[
https://issues.apache.org/jira/browse/NET-419?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Bogdan Drozdowski updated NET-419:
----------------------------------
Attachment: ftp-synchro.diff
The attached file, ftp-synchro.diff, synchronizes all the uses of the control
socket (and its associated readers and writers). This should help in avoiding
the incorrect replies to commands.
It also introduces a boolean that tells if the user has called abort().
Currently all it does is skipping the now-perhaps-unnecessary replies on the
control channel after aborting a transfer.
This patch works for me: the FTP client does not lock because of
synchronization and calling abor() on a separate Thread returns "226 Abort
successful" and the file is not totally transferred. It needs a re-think,
though: do we need to skip the additional answers, so the user can read them?
Perhaps something else should be done?
To abort a transfer as soon as possible, abor() should be called, followed by
closing the Input/OutputStream connected to the transfer. One may call
interrupt() on the transfer Thread (after this, read()/write() should throw an
InterruptedException, which should propagate all the way up to the code calling
the FTP client), but someone noticed that it may not always work. On the other
hand, closing the stream should always work.
> Not possible to call FTPClient.abort() method correctly
> -------------------------------------------------------
>
> Key: NET-419
> URL: https://issues.apache.org/jira/browse/NET-419
> Project: Commons Net
> Issue Type: Bug
> Components: FTP
> Affects Versions: 3.0
> Environment: java version "1.6.0_26"
> Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
> Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)
> Linux cattie 2.6.38-10-generic #46-Ubuntu SMP Tue Jun 28 15:07:17 UTC 2011
> x86_64 x86_64 x86_64 GNU/Linux
> Reporter: Tomas Mysik
> Attachments: ftp-synchro.diff
>
>
> Unfortunately, it seems that there are difficulties of using FTPClient.abort()
> method [1][2]. Also, it is really not clear how the abort() method should be
> called/used at all - if from another thread (as I would expect) then there is
> a problem with
> thread-safety: FTPClient itself is not thread-safe so it means that some
> custom lock/monitor must be used; but this lock will prevent calling abort()
> on
> the FTPClient while it is downloading/uploading file since file
> upload/download
> itself is blocking...
> If I'm wrong and the abort() method works then an example in Javadoc would be
> more than welcome.
> Thanks a lot.
> [1]
> http://apache-commons.680414.n4.nabble.com/Net-FTPClient-abort-problem-td739542.html
> [2] http://www.tikalk.com/java/forums/apache-ftp-client-abort-transfer
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira