GH-3211: Restore timestamp header on consumed messages - #3245
Open
PRAHLAD09-dev wants to merge 1 commit into
Open
GH-3211: Restore timestamp header on consumed messages#3245PRAHLAD09-dev wants to merge 1 commit into
PRAHLAD09-dev wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
FunctionConfiguration#sanitize() was relying on MessageBuilder's internal "no-op fast path" to always construct a fresh GenericMessage. Since GH-2222 removed the SOURCE_TYPE/TARGET_PROTOCOL header manipulation from this method, headerAccessor.isModified() now returns false when no other header changes occur, causing MessageBuilder.build() to return the original Message instance instead of constructing a new GenericMessage. Since only the GenericMessage constructor stamps a timestamp header, this silently removed the timestamp header from every consumed message starting in 4.3.3.
This PR fixes sanitize() to explicitly construct a GenericMessage whenever the fast path is taken, restoring the pre-4.3.3 behavior of always stamping a timestamp header.
What did not change
The TARGET_PROTOCOL/SOURCE_TYPE header logic removed in GH-2222 is intentionally left untouched — that removal fixed a separate bug (incorrect target-protocol values for non-Kafka/Rabbit binders) and reintroducing it was out of scope here.
Testing
Added timestampHeaderIsPresentOnConsumedMessage() in HeaderTests, which sends a message through a functional binding and asserts MessageHeaders.getTimestamp() is non-null on the consumed message. Ran the full spring-cloud-stream and spring-cloud-stream-integration-tests module test suites locally — all passing, no regressions in existing header-related tests.
Fixes #3211