Hi, I have been using the FakeFtpServer for a while now and have noticed that the sessions map grows over time and never gets cleaned up. We are using the framework as a substitute for an external FTP server in our TEST environment and therefore it is left running for days at a time. Unfortunately this means that it grinds to a halt as the number of sessions grows (at 8 connections per minute it lasts less than 24 hours as currently configured).
Looking at the code it seems that this could be resolved by adding a method call at line 153 in the AbstractFtpServer to tidy up the session map by removing entries where the socket is closed and the thread is not alive - and possibly adding an isClosed() method to Session and checking that as well?
Does that sound a reasonable approach or am I in some way using the code inappropriately?
I think a clean up like that would only work if the client closed the connection by issuing the FTP QUIT command (e.g. by calling ftpClient.quit()). I think that is the only way that the thread would be terminated, and even then I think that the socket still would not be closed.
Is your FTP client code issuing the FTP QUIT command (e.g. by calling ftpClient.quit())?
I suspect the problem may not be the session map data structure but rather the fact that the sockets are never explicitly closed. I may be able to add logic to close that socket, but I'd like to try to reproduce the issue. I'll take a look when I get a chance.
See #25 OutOfMemoryError; clean up closed sessions
Fixed for MockFtpServer 2.6.
Log in to post a comment.