-
Notifications
You must be signed in to change notification settings - Fork 1.1k
INT-4397: Fix headers filtering for @Transformer #2445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -139,7 +139,7 @@ public void setNotPropagatedHeaders(String... headers) { | |||
* @param merge true to merge with existing patterns; false to replace. | |||
* @since 5.0.2 | |||
*/ | |||
protected final void updateNotPropagatedHeaders(String[] headers, boolean merge) { | |||
protected void updateNotPropagatedHeaders(String[] headers, boolean merge) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This must be final - it is called from a CTOR in SIK.
The javadoc explicitly explains that.
Exposed so that subclasses can set specific
* headers in a constructor, since {@link #setNotPropagatedHeaders(String...)} is not
* final.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I see now JavaDocs. Not sure why I have missed to read them 😢
The problem that this method nowhere is used from the ctor...
What am I missing? Maybe we should just relax this method and let end-user to deal with it on its own?
I think otherwise I will override the setter and adder in the MessageTransformingHandler
.
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
KafkaProducerMessageHandler
CTOR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, but those headers are not mapped by the AbstractKafkaHeaderMapper
anyway.
Don't we use there a headerMapper
for gateway reply messages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has nothing to do with header mapping either outbound or reply; those headers might be present on the outbound message received by the gateway, and we don't want them to appear in the reply message. Hence they are added to the notPropagatedHeaders
.
getMessageBuilderFactory() | ||
.withPayload(result); | ||
|
||
if (this.selectiveHeaderPropagation) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should move this to a utility to avoid duplicating code (be careful about tangles, though 😄 )
JIRA: https://jira.spring.io/browse/INT-4397 The `AbstractMessageProcessingTransformer` doesn't honor a configured `notPropagatedHeaders` and copies all the request headers to the message to return * Add `setNotPropagatedHeaders()` into the `AbstractMessageProcessingTransformer` and implement there a logic to filter headers, similar to what we have in the `AbstractMessageProducingHandler` * Overrider `updateNotPropagatedHeaders()` in the `MessageTransformingHandler` to propagate `notPropagatedHeaders` to the `AbstractMessageProcessingTransformer` delegate
…opagatedHeaders()` * Override `addNotPropagatedHeaders()` for the `MessageTransformingHandler()` and populate `notPropagatedHeaders` into the target `AbstractMessageProcessingTransformer` from there * Also populate `notPropagatedHeaders` from the `AbstractMessageProcessingTransformer.doInit()` * Implement a `AbstractIntegrationMessageBuilder.filterAndCopyHeadersIfAbsent()` for a general logic to filter `notPropagatedHeaders` and copy the result headers set into the target message if they are absent * Use an new `filterAndCopyHeadersIfAbsent()` in the `AbstractMessageProducingHandler` and `AbstractMessageProcessingTransformer`to avoid code block duplication
JIRA: https://jira.spring.io/browse/INT-4397
The
AbstractMessageProcessingTransformer
doesn't honor a configurednotPropagatedHeaders
and copies all the request headers to themessage to return
setNotPropagatedHeaders()
into theAbstractMessageProcessingTransformer
and implement there a logic to filter headers, similar to what we have
in the
AbstractMessageProducingHandler
updateNotPropagatedHeaders()
in theMessageTransformingHandler
to propagate
notPropagatedHeaders
to theAbstractMessageProcessingTransformer
delegate