Skip to content

GH-3211: Restore timestamp header on consumed messages - #3245

Open
PRAHLAD09-dev wants to merge 1 commit into
spring-cloud:mainfrom
PRAHLAD09-dev:fix/GH-3211-timestamp-header
Open

GH-3211: Restore timestamp header on consumed messages#3245
PRAHLAD09-dev wants to merge 1 commit into
spring-cloud:mainfrom
PRAHLAD09-dev:fix/GH-3211-timestamp-header

Conversation

@PRAHLAD09-dev

Copy link
Copy Markdown

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v4.3.3 no longer adds a header "TIMESTAMP" on kafka messages consumed

1 participant