This is not an issue, but more a possible improvment.
I'm using MockFtpServer successfully for my tests, but on one test I noticed it was really slow (comparing it with an implementation that not use ftp but use local files).
In started to look if my implementation using ftp client was "bad", and then I started to see that the slow part was uploading file to the ftp.
I looked on StorCommandHandler, and then on DefaultSession.readData() and then on DefaultSession.readData(int numBytes).
Here the InputStream is read using the read() method. I'm no expert on InputStream stuff, but debugging the method I saw that the read() returned few byte at each loop... and that seem suspicious.
I tried to switch to Guava ByteStreams.toByteArray() method and my test elapsed time went from 30s to 5s.
I'm not arguing about using Guava in your project (it will be another dependency) but there are probable other plain java solution to make that code faster.
On my project, I resolved replacing StorCommandHandler with a custom one that read the data with guava (with some reflection/nasty stuff.. but it's ok)
Hello,
This is not an issue, but more a possible improvment.
I'm using MockFtpServer successfully for my tests, but on one test I noticed it was really slow (comparing it with an implementation that not use ftp but use local files).
In started to look if my implementation using ftp client was "bad", and then I started to see that the slow part was uploading file to the ftp.
I looked on
StorCommandHandler
, and then onDefaultSession.readData()
and then onDefaultSession.readData(int numBytes)
.Here the
InputStream
is read using theread()
method. I'm no expert on InputStream stuff, but debugging the method I saw that theread()
returned few byte at each loop... and that seem suspicious.I tried to switch to Guava
ByteStreams.toByteArray()
method and my test elapsed time went from 30s to 5s.I'm not arguing about using Guava in your project (it will be another dependency) but there are probable other plain java solution to make that code faster.
On my project, I resolved replacing StorCommandHandler with a custom one that read the data with guava (with some reflection/nasty stuff.. but it's ok)