* 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()); }
方法介绍中未说明,在何种状况下应该使用该方法。可是跟踪代码能够发现
这是一个同步阻塞方法,若是调用错误,会致使程序卡住假死在这里。javascript
卡住代码
String line = _controlInput_.readLine();
其实ftp功能,总结来讲,只有上传和下载。只有在获取返回流时,才须要调用completePendingCommad方法,由于返回流不是马上处理的。因此需用手动调用结束方法。html
public boolean storeFile(String remote, InputStream local) public OutputStream storeFileStream(String remote) public boolean retrieveFile(String remote, OutputStream local) public InputStream retrieveFileStream(String remote)
咱们看到上面4我的方法,其中两个有流返回,另外两个无返回。当调用有返回流方法时,须要手动调用completePendingCommad方法,即第二个和第四个是须要调用completePendingCommad方法,其余两个方法若是调用了,则会产生卡死超时现象。java
不可多加或者漏加,不然会致使程序卡死ui
commons-net FTPClient API存取设计this
Commons-net FTPClient completePendingCommand()常常使程序死掉的缘由分析以及解决方式spa