It seems to be related to "INT-1885 added support for empty remote-file-separator to the FTP Inbound Channel Adapter" - this fragment in org.springframework.integration.file.config.Abstra ctRemoteFileInboundChannelAdapterParser#parseSourc e:
Code:
String remoteFileSeparator = element.getAttribute("remote-file-separator");
if (remoteFileSeparator != null){
synchronizerBuilder.addPropertyValue("remoteFileSeparator", remoteFileSeparator);
}
Initializes the separator to empty unless you explicitly provide a value in the XML config. So the below works fine in 2.0.3, but not in 2.0.4:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sftp="http://www.springframework.org/schema/integration/sftp"
xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:stream="http://www.springframework.org/schema/integration/stream"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration/sftp http://www.springframework.org/schema/integration/sftp/spring-integration-sftp-2.0.xsd
http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream-2.0.xsd">
<sftp:inbound-channel-adapter
id="sftpInboundAdapter"
session-factory="sftpSessionFactory"
cache-sessions="true"
remote-directory="input"
filename-regex="test.*\.txt"
delete-remote-files="true"
local-directory="/tmp/files"
auto-create-local-directory="true"
channel="files">
<integration:poller fixed-delay="5000" error-channel="errorChannel"/>
</sftp:inbound-channel-adapter>
<bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
<property name="host" value="vm"/>
<property name="port" value="22"/>
<property name="user" value=".."/>
<property name="password" value="..."/>
</bean>
<integration:channel id="files"/>
<integration:transformer
input-channel="files" output-channel="fileNames"
expression="'File downloaded: ' + payload.name + '.'"/>
<integration:channel id="fileNames"/>
<stream:stderr-channel-adapter append-newline="true" channel="fileNames"/>
</beans>
Changing the SFTP inbound adapter by adding an explicit remote-file-separator setting like so fixes it again:
Code:
<sftp:inbound-channel-adapter
id="sftpInboundAdapter"
session-factory="sftpSessionFactory"
cache-sessions="true"
remote-directory="input"
remote-file-separator="/"
filename-regex="test.*\.txt"
delete-remote-files="true"
local-directory="/tmp/files"
auto-create-local-directory="true"
channel="files">
<integration:poller fixed-delay="5000" error-channel="errorChannel"/>
</sftp:inbound-channel-adapter>
The cause for all this is that element.getAttribute("remote-file-separator") returns an empty string even if the XML element has no such attribute, so changing it like so will fix the default behavior back to what it was.
The solution is to change org.springframework.integration.file.config.Abstra ctRemoteFileInboundChannelAdapterParser#parseSourc e like so:
Code:
if (element.hasAttribute("remote-file-separator")){
synchronizerBuilder.addPropertyValue("remoteFileSeparator", element.getAttribute("remote-file-separator"));
}
I've opened an issue and attached a patch with unit tests in JIRA - INT-1921.