ftp下载完成后卡在ftpClient.completePendingCommand();

在FTP下载完成后,调用ftpClient.completePendingCommand()可能导致程序卡住不继续执行。该方法是一个同步阻塞操作,如果误用,会造成程序假死。正确使用时机是在涉及返回流的操作,如上传和下载后。只有在调用有返回流的方法时,如上传和下载,才需手动调用completePendingCommand(),否则可能导致卡死超时。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

下载完成后,若有 boolean upNewStatus = ftpClient.completePendingCommand();,到此会停住不往下执行,必须重启,否则不会往下执行
   

 * There are a few FTPClient methods that do not complete the
    * entire sequence of FTP commands to complete a transaction.  These
    * commands require some action by the programmer after the reception
    * of a positive intermediate command.  After the programmer's code
    * completes its actions, it must call this method to receive
    * the completion reply from the server and verify the success of the
    * entire transaction.
   public boolean completePendingCommad() throws IOException;
   {
        return FTPReply.isPositiveCompletion(getReply());
   }

方法介绍中未说明,在何种情况下应该使用该方法。但是跟踪代码可以发现
这是一个同步阻塞方法,如果调用错误,会导致程序卡住假死在这里。
卡住代码
 String line = _controlInput_.readLine()

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值