Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-12933

Camel FTP regression: RemoteFile does not override populateHeaders method



    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.22.1
    • 2.21.4, 2.22.3, 2.23.0
    • camel-ftp
    • None
    • Unknown
    • Regression


      After upgrade from Camel 2.14 to 2.22.1, I have noticed it no longer sets "CamelFileHost" header for Exchange input. After debugging and comparing differences between old and new execution, I have noticed that Camel stopped setting CamelFileHost header after changes in https://github.com/apache/camel/commit/e3a1bdb6a278b5e4910ba4caf3ebe95751cceaee#diff-f9d7a01c99e5d4239aae6b6834cdfc65.

      This happens because previously we had execution chain:


      But after this change we have:

      FtpConsumer->RemoteFileEndpoint.createExchange->GenericFile.bindToExchange->GenericFile.populateHeaders(msg, false)

      This happens because bindToExchange method sets all the headers via populateHeaders. This method is overriden in RemoteFile, and it adds CamelFileHost header.

      public void populateHeaders(GenericFileMessage<T> message) {
          if (message != null) {
              // because there is not probeContentType option 
              // in other file based components, false may be passed
              // as the second argument.
              super.populateHeaders(message, false);
              message.setHeader("CamelFileHost", getHostname());

      But after changes the signature of the parent method was changed from

      public void populateHeaders(GenericFileMessage<T> message) {


      public void populateHeaders(GenericFileMessage<T> message, boolean isProbeContentTypeFromEndpoint) {

      But its signature was not changed in RemoteFile. Since it is missing the @Override annotation, it compiled well and was unnoticed. But now the overridden method in RemoteFile does not get executed, and we end up without CamelFileHost header. It may be unnoticed by those who do not use this header, but if we rely on it, it may be an issue.

      My proposed changes will be:

      1. Add @Override annotation to populateHeaders method in RemoteFile, so the same bug will not happen.
      2. Change its signature to
        public void populateHeaders(GenericFileMessage<T> message, boolean isProbeContentTypeFromEndpoint)

        So it will be called instead of the parent method. If we assume someone already uses this method somehow and we want to make these changes backward compatible, we may just add a new method with this signature and @Override annotation, leaving existing populateHeaders(GenericFileMessage<T> message) without changes.


        Issue Links



              onders Onder Sezgin
              mshalak Maksym Shalak
              0 Vote for this issue
              3 Start watching this issue