-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
In what version(s) of Spring Integration are you seeing this issue?
6.4.1
Describe the bug
After upgrading from previous version (as part of Spring Boot 2.x -> SpringBoot 3.x migration) SftpInboundFileSynchronizer
stopped syncing the files. We have isolated the problem to be related to a situation where the directory to synchronize is a symlink (i.e. last element in the path is a symlink).
To Reproduce
- Create
/tmp/realdir
on SFTP server and place a file (egaaa.txt
there) - Create
/tmp/link
on SFTP server as a symlink pointing to/tmp/realdir
- Configure
SftpInboundFileSynchronizer
to synchronize the content of/tmp/link
Expected behavior
aaa.txt
is downloaded from SFTP to local filesystem
Analysis
SftpInboundFileSynchronizer
(via its parent AbstractInboundFileSynchronizer
) calls list()
method to retrieve the directory content
Line 354 in 478409e
F[] files = session.list(remoteDirectory); |
The problem is that SftpSession
calls lstat
on a file/directory and if it is not reported as a directory (which it isn't since it's a symbolic link), it fails silently and returns empty list.
Lines 104 to 107 in 478409e
SftpClient.Attributes attributes = this.sftpClient.lstat(path); | |
if (!attributes.isDirectory()) { | |
return Stream.of(new SftpClient.DirEntry(remoteFile, path, attributes)); | |
} |
I believe that SftpSession.doList(String path)
method should call stat()
instead of lstat()
so that it resolves also symlinks.