Affects Version/s: 0.5.0
Fix Version/s: 0.6.0
Environment:JDK 1.6.0_18 (32bit) running on Win 7 (64 bit). I've a fairly out-of-the-box Mina SSHD / sftp config. I'm serving from my local Windows machine.
Uploading a file via SFTP leaves the file in a locked state. Specifically, when I upload a file using sftpd, the file is locked in windows, even after the upload is complete.
I verified this by using Yourkit Profiler (see attached screenshots). There are two writes to the file
- first: NativeSshFile.truncate() erases the old file. This is what fails to clean up
- second: NativeSshFile.createOutputStream(). This is properly closed after use.
The fix is simple. In the truncate() method, close the RandomAccessFile after it is created. See attached patch.
I tested this by putting the truncate method in a subclass of NativeSshFile and it solved the problem.
After applying the patch to the Mina SSHD source code, I ran "mvn test" which passed.