Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6AE4F9AAE for ; Mon, 23 Apr 2012 12:28:00 +0000 (UTC) Received: (qmail 16200 invoked by uid 500); 23 Apr 2012 12:27:59 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 15995 invoked by uid 500); 23 Apr 2012 12:27:59 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 15895 invoked by uid 99); 23 Apr 2012 12:27:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Apr 2012 12:27:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Apr 2012 12:27:55 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 6881A40ADEB for ; Mon, 23 Apr 2012 12:27:34 +0000 (UTC) Date: Mon, 23 Apr 2012 12:27:34 +0000 (UTC) From: "Sebb (JIRA)" To: issues@commons.apache.org Message-ID: <1361530441.4671.1335184054439.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <357158860.2557.1335088176665.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Resolved] (NET-460) _retrieveFile() blocks calling thread, on FTP I/O till the time file transfer is complete MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/NET-460?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Sebb resolved NET-460. ---------------------- Resolution: Duplicate > _retrieveFile() blocks calling thread, on FTP I/O till the time file transfer is complete > ----------------------------------------------------------------------------------------- > > Key: NET-460 > URL: https://issues.apache.org/jira/browse/NET-460 > 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: FTPClient.java , 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: FTPClient.java > 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 else. > 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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira