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

Camel FTP regression: RemoteFile does not override populateHeaders method

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.22.1
    • Fix Version/s: 2.21.4, 2.22.3, 2.23.0
    • Component/s: camel-ftp
    • Labels:
      None
    • Estimated Complexity:
      Unknown
    • Regression:
      Regression

      Description

      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:

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

      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) {
      

      to

      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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                onders Onder Sezgin
                Reporter:
                mshalak Maksym Shalak
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: