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

Removed String headers appears in next endpoints

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Invalid
    • 2.22.5
    • None
    • camel-core
    • None
    • Unknown

    Description

      Hello,

      I create this issue because we noticed a strange behaviour with headers in apache camel. 
      I say "strange behaviour" because we didn't find anything in documentation about it. Maybe it's a normal behaviour, and we would like to see the part of documentation which talks about it.

      Context

      In our project, we have a bean which computes next endpoints and gives them to the recipientList. It looks like this :

      <routes>
          <route>
             <!-- our logic -->
              <recipientList>
                  <method ref="ourBean" method="ourMethod"/>
              </recipientList>
          </route>
      </routes>
      

      In ourMethod(), we manipulate headers(create, modify, remove).

      Issue

      However, inside ourMethod(), when we remove a header with

       exchange.getIn().removeHeader(headerToRemove)

      The removed headers appears again in the next route.

       

      ourMethod looks like this :

      public String ourMethod(Exchange exchange,@Header("ourHeader") String headerToRemove) {
         //some logic
      
          if (!StringUtils.isEmpty(headerToRemove)){
            //some logic
            exchange.getIn().removeHeader(headerToRemove);
          }
      }
      

      So with this code, the header is removed from exchange, but re-appears in the next endpoint.

      We have a workaround :

      public String ourMethod(Exchange exchange,@Header("ourHeader") String headerToRemove) {
         //some logic
      
          if (!StringUtils.isEmpty(headerToRemove)){
            //some logic
            exchange.getIn().setHeader(headerToRemove, "");
          }
      }
      

      Instead of removing it, we set its value to an empty string.

      Explanations

      We're puzzled, we don't understand if this should be a correct behaviour or not. If yes, can you give us some explanations ?

      Best Regards,
      Vlad

      Attachments

        Activity

          People

            Unassigned Unassigned
            Vlad_96_T Vladislav Sokolov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: