Closed sergei-zachesov closed 1 month ago
Were there any interesting logs or stacktraces from FakeFtpServer?
And which FTPClient
call(s) were executed before completePendingCommand()
?
It looks like the client is hanging on the controlInput.readLine();
.. i.e., the FakeFtpServer is not sending any response.
Is it possible you have an extra call to FTPClient::completePendingCommand
, or that is being called after an FTPClient method where it should not?
I am able to execute this fine, within the context of the integration tests:
InputStream inputStream = ftpClient.retrieveFileStream(FILE1)
ftpClient.completePendingCommand();
Now if I add an extra call to ftpClient.completePendingCommand();
, then it will hang.
Thanks for the answer!
In my code, I used the inputStream.close()
first, then FTPClient::completePendingCommand
. It worked with real ftp. But not with a fake one. Now I swapped them and it worked with fake. I'll try to experiment again.
Which of the FTPClient methods are you calling before that? completePendingCommand
is only needed for FTPClient appendFileStream, retrieveFileStream, storeFileStream, storeUniqueFileStream (both overloaded methods), so I assume it is one of those.
BTW, this works for me as well:
InputStream inputStream = ftpClient.retrieveFileStream(FILE1)
inputStream.close()
ftpClient.completePendingCommand();
Were there any interesting logs or stacktraces from FakeFtpServer? And which
FTPClient
call(s) were executed beforecompletePendingCommand()
?It looks like the client is hanging on the
controlInput.readLine();
.. i.e., the FakeFtpServer is not sending any response.
Yes, that assumption was correct. Called several times or without using retrieveFileStream
methods.
I have added some integration tests using FTPClient that call retrieveFileStream()
, then close the InputStream, and then calls completePendingCommand()
(commit). That seems to be the required/acceptable sequence of calls. Extra calls to completePendingCommand()
will definitely hang, but so far I don't think that is "wrong" or needs to be changed. See FTPClient #retrieveFileStream.
Not sure what else, if anything, to do for this issue.
Closing. Reopen if needed.
I use:
During a normal connection to the server, method FTPClient::completePendingCommand works as expected. But if you use the same code for FakeFtpServer, it hangs.
If you look at the stack. Hanging in this place: FTPClient::completePendingCommand -> FTPClient::getReply(true) -> String line = controlInput.readLine();
If you call the FTPClient::getReply method anywhere, the same thing happens.