[
https://issues.apache.org/jira/browse/CAMEL-14602?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17041222#comment-17041222
]
Andrea Cosentino commented on CAMEL-14602:
------------------------------------------
First ask on the users mailing list. Also 2.22.x is really old version.
> Removed String headers appears in next endpoints
> ------------------------------------------------
>
> Key: CAMEL-14602
> URL: https://issues.apache.org/jira/browse/CAMEL-14602
> Project: Camel
> Issue Type: Bug
> Components: camel-core
> Affects Versions: 2.22.5
> Reporter: Vladislav Sokolov
> Priority: Minor
>
> 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.
> h2. Context
> In our project, we have a bean which computes next endpoints and gives them
> to the recipientList. It looks like this :
> {code:java}
> <routes>
> <route>
> <!-- our logic -->
> <recipientList>
> <method ref="ourBean" method="ourMethod"/>
> </recipientList>
> </route>
> </routes>
> {code}
> In ourMethod(), we manipulate headers(create, modify, remove).
> h2. Issue
> However, inside ourMethod(), when we remove a header with
> {code:java}
> exchange.getIn().removeHeader(headerToRemove){code}
> The removed headers appears again in the next route.
>
> ourMethod looks like this :
> {code:java}
> public String ourMethod(Exchange exchange,@Header("ourHeader") String
> headerToRemove) {
> //some logic
> if (!StringUtils.isEmpty(headerToRemove)){
> //some logic
> exchange.getIn().removeHeader(headerToRemove);
> }
> }
> {code}
> So with this code, the header is removed from exchange, but re-appears in the
> next endpoint.
> We have a workaround :
> {code:java}
> public String ourMethod(Exchange exchange,@Header("ourHeader") String
> headerToRemove) {
> //some logic
> if (!StringUtils.isEmpty(headerToRemove)){
> //some logic
> exchange.getIn().setHeader(headerToRemove, "");
> }
> }
> {code}
> Instead of removing it, we set its value to an empty string.
> h2. 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
--
This message was sent by Atlassian Jira
(v8.3.4#803005)