Skip to content

Sftp Session cannot open directory from the absolute path #3974

@jonchngau

Description

@jonchngau

In what version(s) of Spring Integration are you seeing this issue? 6.0.0

Describe the bug
After upgrading to 6.0.0,
When using spring integration with sftp inbound, there is exception of SSH_FX_NO_SUCH_FILE thrown when doing file synchronization from remote to local.
After troubleshooting, it is related to SftpSession.doList()
it is now removing all leading and trailing slash.
So, if I used /a/b/c as remote directory in the synchronization.
remotePath = a/b/c
remoteDir = a/b
remoteFile = c

and it will cause the above error, because it regards remoteDir as relative path.
E.g. if home directory is "/home/user", then it will locate /home/user/a/b instead of /a/b

I have tried to extends the DefaultSftpSessionFactory and SftpSession,
it works normally after i change the following code

String remotePath = StringUtils.trimTrailingCharacter(StringUtils.trimLeadingCharacter(path, '/'), '/');

to

String remotePath = StringUtils.trimTrailingCharacter(path, '/');

Please advice the purpose of trim leading slash.

To Reproduce

login to sftp server with remote directory not under home directory

Expected behavior

sftp inbound or outbound to directory outside home directory should be supported.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions