Skip to content

WIP: Removing WindowedSerializer interface from public class implementations#21852

Draft
siddharthaDevineni wants to merge 1 commit intoapache:trunkfrom
siddharthaDevineni:poc-windowed-serializer-cleanup
Draft

WIP: Removing WindowedSerializer interface from public class implementations#21852
siddharthaDevineni wants to merge 1 commit intoapache:trunkfrom
siddharthaDevineni:poc-windowed-serializer-cleanup

Conversation

@siddharthaDevineni
Copy link
Copy Markdown
Contributor

@siddharthaDevineni siddharthaDevineni commented Mar 23, 2026

POC: Attempt to clean up WindowedSerializer leak (https://issues.apache.org/jira/browse/KAFKA-20313)

Removing WindowedSerializer interface from public API.

Changes Made

  • Removed implements WindowedSerializer from SessionWindowedSerializer and TimeWindowedSerializer
  • Updated WindowedStreamPartitioner to accept Serializer<Windowed<K>> instead of WindowedSerializer<K>
  • Internal code uses instanceof checks to access serializeBaseKey functionality
  • Updated tests and removed unused imports

Problems Discovered

Architectural Issues:

  • Internal code (WindowedStreamPartitioner) now depends on public classes via instanceof checks
  • Creates backward dependency: internal -> public (bad coupling)
  • instanceof checks are brittle and non-extensible

Root Cause:
WindowedStreamPartitioner needs to serialize the base key (not the windowed wrapper) for partitioning. This functionality exists in the method serializeBaseKey(), which is implemented in the public SessionWindowedSerializer and TimeWindowedSerializer classes.

serializeBaseKey() serves a real architectural need and it cannot be removed without redesigning the partitioning logic in WindowedStreamPartitioner, i mean, how it obtains the serializedKey from windowedKey.

Conclusion/Thoughts

Every attempt to hide this method creates either:

  • Interface leaking (public implements internal interface), or
  • Bad coupling (internal depends on public classes)

So, should we accept serializeBaseKey() as legitimate public API rather than treating it as leaked internals?
If yes, we can properly document it and make it officially public.

@mjsax - Looking for your guidance on the right direction. Please let me know your suggestions.
Thanks.

…ions.

Changes made:
  - Removed implementations from SessionWindowedSerializer and TimeWindowedSerializer
  - Updated WindowedStreamPartitioner to use instanceof checks
  - Updated internal references
@github-actions github-actions bot added triage PRs from the community streams small Small PRs labels Mar 23, 2026
@siddharthaDevineni siddharthaDevineni marked this pull request as draft March 23, 2026 10:47
@siddharthaDevineni siddharthaDevineni changed the title CHG: Removing WindowedSerializer interface from public class implementations WIP: Removing WindowedSerializer interface from public class implementations Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

small Small PRs streams triage PRs from the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant