commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Agent Vinod (JIRA)" <>
Subject [jira] [Commented] (NET-460) _retrieveFile() blocks calling thread, on FTP I/O till the time file transfer is complete
Date Wed, 25 Apr 2012 16:56:20 GMT


Agent Vinod commented on NET-460:

thanks for the prompt response. 
Even the vsftpd server on ununtu 11.10 displays the same problem as mentioned.
Implementing a new method, looks like a reasonable approach.
> _retrieveFile() blocks calling thread, on FTP I/O till the time file transfer is complete
> -----------------------------------------------------------------------------------------
>                 Key: NET-460
>                 URL:
>             Project: Commons Net
>          Issue Type: Improvement
>          Components: FTP
>    Affects Versions: 3.1
>         Environment: linux/windows
>            Reporter: Agent Vinod
>              Labels: newbie, patch
> The Function _retrieveFile in file: , does not respond to interrupts from
calling thread.
> For Example:
> A Basic FTP Client Application has 1 Main (Parent) Thread and 1 Child Thread.
> Main (Parent) thread handles all functions except the FtpClient download/upload.
> Child Thread handles only FtpClient related functions mainly (_retrieveFile()) etc.
> Steps to reproduce:
> 1) Main Thread has initiated child Thread .
> 2) Child thread is presently downloading a file using _retrieveFile(String command, String
remote, OutputStream local) . 
> 3) After some time, Main Thread fires Interrupt on child Thread to stop( Abort) download.
> Expected behavior:
> Child Thread immediately aborts download and dies.
> Observed behavior:
> Child Thread blocks on retrieveFile(String command, String remote, OutputStream local)
till the file finishes download. 
> Only after this ,does the Child thread respond to any interrupt from Parent Thread.
> My Workaround:
> file:
> Class: FTPClient    
> Step 1: declare private Socket mySocket;
> Step 2: In the function : protected boolean _retrieveFile(String command, String remote,
OutputStream local) throws IOException{}
> Comment out:  Socket socket;
> and instead use:  mySocket ( declared as global in step1)
> Step 3:  In the function : public boolean abort() throws IOException
> Add a statement: Util.closeQuietly(mySocket);
> before the statement: return FTPReply.isPositiveCompletion(abor());
> This way, every time the Main Thread calls abort(), the download active and blocked on
mySocket in _retrieveFile() is immediately interrupted and stopped.
> raising an immediate Exception and thus stopping the Child thread (of course one needs
to catch this exception properly).
> I am not sure if this is the right way of doing it and am afraid if this breaks something
> Requesting the core developers to look into a better solution to this workaround.
> thank

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message