[
https://issues.apache.org/jira/browse/CAMEL-7141?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Joe Luo reopened CAMEL-7141:
----------------------------
Hi, Willem
Apologies but I have to reopen this JIRA since the previous patch I provided
caused a new problem. I'll attach a revised patch with a new junit test case to
this ticket.
Here is the code changes in NettyHttpEndpoint.java class:
{code}
public void setHeaderFilterStrategy(HeaderFilterStrategy
headerFilterStrategy) {
this.headerFilterStrategy = headerFilterStrategy;
+ if (getNettyHttpBinding() != null) {
+
getNettyHttpBinding().setHeaderFilterStrategy(headerFilterStrategy);
+ }
{code}
Basically it allows this method to modify NettyHttpComponent's member object
"nettyHttpBinding" simply by setting a new headerFilterStrategy to it. As a
result, the component's member object contains a different headerFilterStrategy
rather than default one that created in component's default constructor. It is
ok if we only have one netty http endpoint created. Otherwise, the next
endpoint will be created with a non-default headerFilterStrategy that is from
previous endpoint.
The fix is quite simple: in this case, we should not touch component's
nettyHttpBinding object at all. Instead, if we have configured a custom
headerFilterStrategy on endpoint uri, we should create a new
DefaultNettyHttpBinding object with the headerFilterStrategy for the current
endpoint.
I also reverted back some changes to initialize default NettyHttpConfiguration,
NettyHttpHeaderFilterStrategy and DefaultNettyHttpBinding object in
NettyHttpComponent's default constructor since it is reasonable to create them
upfront for the component.
> Custom HeaderFilterStrategy does not work when set it on either component or
> endpoint uri
> -----------------------------------------------------------------------------------------
>
> Key: CAMEL-7141
> URL: https://issues.apache.org/jira/browse/CAMEL-7141
> Project: Camel
> Issue Type: Bug
> Components: camel-netty-http
> Affects Versions: 2.12.2
> Reporter: Joe Luo
> Assignee: Willem Jiang
> Fix For: 2.12.3, 2.13.0
>
> Attachments: NettyHttpHeaderFilterBug.patch
>
>
> Setting custom HeaderFilterStrategy on either NettyHttpComponent or
> NettyHttpEndpoint uri does not work. The only way to get it to work is to
> create a NettyHttpBinding bean and set the custom HeaderFilterStrategy as a
> property of the NettyHttpBinding bean and then set the custom
> NettyHttpBinding bean onto either NettyHttpComponent and NettyHttpEndpoint
> uri.
> The reason it does not work was that when applying the custom
> HeaderFilterStrategy, it is not set on NettyHttpBinding object as the
> NettyHttpBinding object always uses default HeaderFilterStrategy.
> I have attached the patch file. It might not be necessary to modify
> NettyHttpComponent class but I thought it'd be better to initialize
> configuration, nettyBinding and headerFilterStrategy in their getter method
> only when needed rather than in constructor of the NettyHttpComponent.
--
This message was sent by Atlassian JIRA
(v6.2#6252)