GH-11121: Fix SftpSession.listNames() for root directory wildcard paths#11122
Open
yangadam wants to merge 1 commit into
Open
GH-11121: Fix SftpSession.listNames() for root directory wildcard paths#11122yangadam wants to merge 1 commit into
yangadam wants to merge 1 commit into
Conversation
artembilan
requested changes
Jun 16, 2026
artembilan
left a comment
Member
There was a problem hiding this comment.
Well, looks like you have not checked the fix locally before opening PR:
SftpOutboundTests > testFtpOutboundGatewayInsideChain() FAILED
org.springframework.messaging.MessageHandlingException at SftpOutboundTests.java:192
Caused by: org.springframework.messaging.MessagingException at SftpOutboundTests.java:192
Caused by: java.lang.NullPointerException at SftpOutboundTests.java:192
Please, ensure you run ./gradlew "spring-integration-sftp:check locally before pushing to PR.
Thanks
Author
Thanks for running the build. After debugging, I found that the failure was caused by the lack of mocking for the I can add the mocking, but I need to confirm whether it is acceptable to call |
…ry wildcard paths
Change `lastIndex > 0` to `lastIndex >= 0` in `SftpSession.doList()` so
that root-level paths like `/*` are correctly split into directory and
file components. Previously, `lastIndexOf('/')` returning `0` was not
handled, causing the entire path to be treated as a directory name.
Fixes: spring-projectsgh-11121
Signed-off-by: Adam Yang <yangmm.adam@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SftpSession.listNames("/*")throwsSftpException: SSH_FX_NO_SUCH_FILEbecause the path parsing inSftpSession.list()useslastIndex > 0to detect the/separator. For root-level paths like/*,lastIndexOf('/')returns0, which is excluded by the> 0check. This causes the entire path/*to be treated as a literal directory name instead of being split into directory/and file pattern*.Changes
lastIndex > 0tolastIndex >= 0inSftpSession.list()so root directory paths are correctly parsedlsRootWildcard()that reproduces the issue and verifies the fixFixes: gh-11121
Signed-off-by: Adam Yang yangadam@users.noreply.github.com