You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "UladzislauBlok (via GitHub)" <gi...@apache.org> on 2026/03/14 19:06:24 UTC
[PR] KAFKA-20173: Propagate headers into serde 4/N [kafka]
UladzislauBlok opened a new pull request, #21755:
URL: https://github.com/apache/kafka/pull/21755
Follow-up for:
- https://github.com/apache/kafka/pull/21490
- https://github.com/apache/kafka/pull/21536
- https://github.com/apache/kafka/pull/21681
This PR fixes headers propagation in `SessionWindowedSerializer` and `TimeWindowedSerializer` so they works as expected (from headers propagation perspective), but we still need to update partitioner (currently it propagates `mocked` headers): https://issues.apache.org/jira/browse/KAFKA-20197
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20173: Propagate headers into serde 4/N [kafka]
Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax merged PR #21755:
URL: https://github.com/apache/kafka/pull/21755
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20173: Propagate headers into serde 4/N [kafka]
Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on code in PR #21755:
URL: https://github.com/apache/kafka/pull/21755#discussion_r2937173849
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/WindowedSerializer.java:
##########
@@ -16,10 +16,11 @@
*/
package org.apache.kafka.streams.kstream.internals;
+import org.apache.kafka.common.header.Headers;
import org.apache.kafka.common.serialization.Serializer;
import org.apache.kafka.streams.kstream.Windowed;
public interface WindowedSerializer<T> extends Serializer<Windowed<T>> {
- byte[] serializeBaseKey(String topic, Windowed<T> data);
+ byte[] serializeBaseKey(String topic, Headers headers, Windowed<T> data);
Review Comment:
Yes, but the problem is, that `serializeBaseKey` is inherited by public classes `TimeWindowedSerializer` and `SessionWindowedSerializer`, and thus this method is (unintentionally) part of the public API, even if this interface itself is not public :(
That's why I filed KAFKA-20313...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20173: Propagate headers into serde 4/N [kafka]
Posted by "UladzislauBlok (via GitHub)" <gi...@apache.org>.
UladzislauBlok commented on code in PR #21755:
URL: https://github.com/apache/kafka/pull/21755#discussion_r2936484529
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/WindowedSerializer.java:
##########
@@ -16,10 +16,11 @@
*/
package org.apache.kafka.streams.kstream.internals;
+import org.apache.kafka.common.header.Headers;
import org.apache.kafka.common.serialization.Serializer;
import org.apache.kafka.streams.kstream.Windowed;
public interface WindowedSerializer<T> extends Serializer<Windowed<T>> {
- byte[] serializeBaseKey(String topic, Windowed<T> data);
+ byte[] serializeBaseKey(String topic, Headers headers, Windowed<T> data);
Review Comment:
I had the same thought when making the change, but I decided that since this interface is effectively internal (even though the method is public), we're free to change it. If we want to treat it as a public API, we'd definitely need to add a default method instead
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20173: Propagate headers into serde 4/N [kafka]
Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on code in PR #21755:
URL: https://github.com/apache/kafka/pull/21755#discussion_r2936110075
##########
streams/src/test/java/org/apache/kafka/streams/kstream/TimeWindowedSerializerTest.java:
##########
@@ -130,7 +131,12 @@ public void shouldPassHeadersToUnderlyingSerializer() {
testSerializer.serialize("dummy", headers, data);
- verify(mockSerializer).serialize(anyString(), eq(headers), eq(key));
+ verify(mockSerializer, times(1)).serialize(anyString(), eq(headers), eq(key));
+ verify(mockSerializer, never()).serialize(anyString(), eq(key));
+
+ testSerializer.serializeBaseKey("dummy", headers, data);
+
+ verify(mockSerializer, times(2)).serialize(anyString(), eq(headers), eq(key));
Review Comment:
Same. Should we verify the topic name, too?
##########
streams/src/test/java/org/apache/kafka/streams/kstream/SessionWindowedSerializerTest.java:
##########
@@ -130,7 +131,12 @@ public void shouldPassHeadersToUnderlyingSerializer() {
testSerializer.serialize("dummy", headers, data);
- verify(mockSerializer).serialize(anyString(), eq(headers), eq(key));
+ verify(mockSerializer, times(1)).serialize(anyString(), eq(headers), eq(key));
+ verify(mockSerializer, never()).serialize(anyString(), eq(key));
+
+ testSerializer.serializeBaseKey("dummy", headers, data);
+
+ verify(mockSerializer, times(2)).serialize(anyString(), eq(headers), eq(key));
Review Comment:
We know that the topic name is set to `"dummy"`. Might be better to verify, too? Similar above.
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/WindowedSerializer.java:
##########
@@ -16,10 +16,11 @@
*/
package org.apache.kafka.streams.kstream.internals;
+import org.apache.kafka.common.header.Headers;
import org.apache.kafka.common.serialization.Serializer;
import org.apache.kafka.streams.kstream.Windowed;
public interface WindowedSerializer<T> extends Serializer<Windowed<T>> {
- byte[] serializeBaseKey(String topic, Windowed<T> data);
+ byte[] serializeBaseKey(String topic, Headers headers, Windowed<T> data);
Review Comment:
This change, and the corresponding related ones, made me realize some other issue. Of course, root cause is unrelated to this PR, but this change implies a public API change... I filed https://issues.apache.org/jira/browse/KAFKA-20313 for future cleanup.
But I am wondering if we need to do it differently for backward compatibility, and add a new overload which take `headers` with a default impl that calls the existing one dropping the headers?
We would also need to documen this on the KIP. \cc @aliehsaeedii
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20173: Propagate headers into serde 4/N [kafka]
Posted by "UladzislauBlok (via GitHub)" <gi...@apache.org>.
UladzislauBlok commented on code in PR #21755:
URL: https://github.com/apache/kafka/pull/21755#discussion_r2937181033
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/WindowedSerializer.java:
##########
@@ -16,10 +16,11 @@
*/
package org.apache.kafka.streams.kstream.internals;
+import org.apache.kafka.common.header.Headers;
import org.apache.kafka.common.serialization.Serializer;
import org.apache.kafka.streams.kstream.Windowed;
public interface WindowedSerializer<T> extends Serializer<Windowed<T>> {
- byte[] serializeBaseKey(String topic, Windowed<T> data);
+ byte[] serializeBaseKey(String topic, Headers headers, Windowed<T> data);
Review Comment:
I see. I already changed it to be default method
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20173: Propagate headers into serde 4/N [kafka]
Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on PR #21755:
URL: https://github.com/apache/kafka/pull/21755#issuecomment-4064077945
Thanks for the PR. Merged to trunk.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org