-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
Spring Integration Sftp 6.0/Spring Boot 3.0/Java 17/Kotlin 1.7.22
We have upgraded our project from Spring Boot 2.7.5 to Spring Boot 3.0. Some functions of the Spring Integration Sftp is broken.
In integration 6.0 Sftp, it uses Apache SSHD instead of the legacy jsch.
There is a IntegrationFlow
to list remote files.
@Bean
fun listSftpFolderOutboundFlow(sftpSessionFactory: SessionFactory<SftpClient.DirEntry>): IntegrationFlow =
IntegrationFlow
.from("listSftpChannel")
.handle(
Sftp.outboundGateway(sftpSessionFactory, AbstractRemoteFileOutboundGateway.Command.LS, "payload")
.options(AbstractRemoteFileOutboundGateway.Option.RECURSIVE)
)
.transform<List<SftpFileInfo>, List<String>> { it.map { s -> s.toString() }.toList() }
.channel("replyListSftpChannel")
.get()
It worked well in integration 5/Spring 2.7.5. When passing an empty string as the message payload
, it will display all files in the sftp user home root folder.
But when upgraded to integration 6.0, it will throw the exception.
java.lang.IllegalArgumentException: No remote path
at org.apache.sshd.common.util.ValidateUtils.createFormattedException(ValidateUtils.java:213)
at org.apache.sshd.common.util.ValidateUtils.throwIllegalArgumentException(ValidateUtils.java:179)
at org.apache.sshd.common.util.ValidateUtils.checkTrue(ValidateUtils.java:156)
at org.apache.sshd.common.util.ValidateUtils.checkNotNullAndNotEmpty(ValidateUtils.java:56)
at org.apache.sshd.sftp.client.impl.SftpIterableDirEntry.<init>(SftpIterableDirEntry.java:44)
at org.apache.sshd.sftp.client.impl.AbstractSftpClient.readDir(AbstractSftpClient.java:1153)
at org.springframework.integration.sftp.session.SftpSession.doList(SftpSession.java:99)
at org.springframework.integration.sftp.session.SftpSession.list(SftpSession.java:69)
at org.springframework.integration.sftp.session.SftpSession.list(SftpSession.java:52)
at org.springframework.integration.file.remote.session.CachingSessionFactory$CachedSession.list(CachingSessionFactory.java:227)
at org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.listFilesInRemoteDir(AbstractRemoteFileOutboundGateway.java:993)
at org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.ls(AbstractRemoteFileOutboundGateway.java:958)
at org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.lambda$doLs$6(AbstractRemoteFileOutboundGateway.java:608)
at org.springframework.integration.file.remote.RemoteFileTemplate.execute(RemoteFileTemplate.java:452)
at org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.doLs(AbstractRemoteFileOutboundGateway.java:607)
at org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.handleRequestMessage(AbstractRemoteFileOutboundGateway.java:584)
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:136)
at org.springframework.integration.handler.AbstractMessageHandler.doHandleMessage(AbstractMessageHandler.java:106)
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:74)
at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:115)
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:133)
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:106)
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:72)
at org.springframework.integration.channel.AbstractMessageChannel.sendInternal(AbstractMessageChannel.java:368)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:322)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:292)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:187)
at org.springframework.messaging.core.GenericMessagingTemplate.doSendAndReceive(GenericMessagingTemplate.java:233)
at org.springframework.messaging.core.GenericMessagingTemplate.doSendAndReceive(GenericMessagingTemplate.java:47)
at org.springframework.messaging.core.AbstractMessagingTemplate.sendAndReceive(AbstractMessagingTemplate.java:46)
at org.springframework.integration.core.MessagingTemplate.sendAndReceive(MessagingTemplate.java:97)
at org.springframework.integration.gateway.MessagingGatewaySupport.doSendAndReceive(MessagingGatewaySupport.java:622)
at org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceive(MessagingGatewaySupport.java:551)
at org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceive(MessagingGatewaySupport.java:519)
at org.springframework.integration.gateway.GatewayProxyFactoryBean.sendOrSendAndReceive(GatewayProxyFactoryBean.java:661)
at org.springframework.integration.gateway.GatewayProxyFactoryBean.invokeGatewayMethod(GatewayProxyFactoryBean.java:584)
at org.springframework.integration.gateway.GatewayProxyFactoryBean.doInvoke(GatewayProxyFactoryBean.java:550)
at org.springframework.integration.gateway.GatewayProxyFactoryBean.invoke(GatewayProxyFactoryBean.java:540)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:218)
at jdk.proxy3/jdk.proxy3.$Proxy104.listRemoteFolder(Unknown Source)
Reproduce example: https://github.com/hantsy/spring-puzzles/blob/master/integration-sftp
Replace the "si.sftp.sample" with an empty String in this line, run this test it will throw above example.