Spring Integration
  1. Spring Integration
  2. INT-2477

Allow for the ControlEncoding to be set via the AbstractFtpSessionFactory

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Complete
    • Affects Version/s: 2.1 GA
    • Fix Version/s: 2.1.1, 2.2 M1
    • Component/s: FTP/SFTP Support
    • Labels:
      None
    • Environment:
      Mac OS X, using apache-ftpserver-1.0.6

      Description

      Ran into a scenario where I wanted to send files with UTF encoded filenames. Testing against Apache FTP Server using and FTP Outbound Channel Adapter caused and java.io.IOException to be thrown with the following message:

      Server replied with: 501 Invalid character in command
      

      In the server logs you may see something like:

      [ WARN] 2012-03-16 00:00:18,939 [admin] [127.0.0.1] EXCEPTION :
      org.apache.mina.filter.codec.ProtocolDecoderException: java.nio.charset.MalformedInputException: Input length = 1 (Hexdump: 53 54 4F 52 20 2F 31 31 31 A3 3F A2 3F 24 24 24 24 24 A7 20 20 73 64 66 20 20 20 73 64 66 0D 0A)
      	at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:251)
      	at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
      	at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
      	at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:796)
      	at org.apache.mina.core.filterchain.IoFilterEvent.fire(IoFilterEvent.java:75)
      	at org.apache.mina.core.session.IoEvent.run(IoEvent.java:63)
      	at org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTask(OrderedThreadPoolExecutor.java:780)
      	at org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTasks(OrderedThreadPoolExecutor.java:772)
      	at org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.run(OrderedThreadPoolExecutor.java:714)
      	at java.lang.Thread.run(Thread.java:680)
      Caused by: java.nio.charset.MalformedInputException: Input length = 1
      	at java.nio.charset.CoderResult.throwException(CoderResult.java:260)
      	at org.apache.mina.core.buffer.AbstractIoBuffer.getString(AbstractIoBuffer.java:1675)
      	at org.apache.mina.filter.codec.textline.TextLineDecoder.decodeAuto(TextLineDecoder.java:275)
      	at org.apache.mina.filter.codec.textline.TextLineDecoder.decode(TextLineDecoder.java:186)
      	at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:241)
      	... 9 more
      
      

      Used Spring Integration configuration:

      ...
      
      <int-ftp:outbound-channel-adapter channel="filesIn" session-factory="ftpClientFactory" remote-directory="/" charset="UTF-8"/>
      
      <bean id="ftpClientFactory" 
      	  class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
      		<property name="host" value="localhost"/>
      		<property name="port" value="2121"/>
      		<property name="username" value="admin"/>
      		<property name="password" value="admin"/>
      		<property name="clientMode" value="0"/>
      		<property name="fileType" value="2"/>
      		<property name="bufferSize" value="100000"/>
      </bean>
      ...
      

      Cause:

      Currently you cannot set the following property on the underlying FTPClient (https://commons.apache.org/net/api-3.1/org/apache/commons/net/ftp/FTPClient.html).

      https://commons.apache.org/net/api-3.1/org/apache/commons/net/ftp/FTP.html#setControlEncoding(java.lang.String)

      client.setControlEncoding("utf-8");
      

        Activity

        Show
        Shane Witbeck added a comment - Pull request is https://github.com/SpringSource/spring-integration/pull/386

          People

          • Assignee:
            Shane Witbeck
            Reporter:
            Gunnar Hillert
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: