For the feature I am building, I need to use SFTP to fetch files to process. When it comes to large files, I want to be able to pick up a file for processing only when its been completely written. In order to achieve this, I tried the following combination suggesting the file age should be 10 minutes or more.
This did not work as expected and kept picking up the files in the next poll as soon as the write has started. I found the following while debugging.
In class SftpChangedExclusiveReadLockStrategy,
long startTime = (new Date()).getTime(); ==> returns time in milliseconds as long
newLastModified = f.getAttrs().getMTime(); ==> returns time in seconds as int casted to long.
Hence when the following check is made, the comparison becomes to be between newLastModified which is in seconds and newOlderThan in milliseconds hence never quite honoring the readLockMinAge specified.
(minAge != 0 && newLastModified < newOlderThan)
It looks like there should be
newLastModified = f.getAttrs().getMTime() * 1000;
to convert this to milliseconds.