[KafkaIO] Remove build support for Kafka clients before 3.9.2#39284
[KafkaIO] Remove build support for Kafka clients before 3.9.2#39284sjvanrossum wants to merge 7 commits into
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request modernizes the KafkaIO module by standardizing on Kafka client version 3.9.2. By removing support for older client versions, the project reduces maintenance overhead and enables the adoption of newer Kafka features. The changes involve updating Gradle build configurations, removing deprecated sub-projects, and adjusting test infrastructure to align with the updated Kafka server APIs. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request upgrades the Kafka dependency version from 2.4.1 to 3.9.2, cleans up several legacy Kafka integration test modules, and adapts the codebase to Kafka's updated APIs (such as replacing KafkaServerStartable with KafkaServer and updating consumer close signatures). The reviewer's feedback highlights a critical improvement: instead of using fragile, Scala-compiler-generated default argument methods (like $lessinit$greater$default$2()) directly in Java when initializing KafkaServer, the code should explicitly pass standard Scala/Java instances to ensure stability across compiler versions.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| KafkaServer server = | ||
| new KafkaServer( | ||
| new KafkaConfig(props), | ||
| KafkaServer.$lessinit$greater$default$2(), | ||
| KafkaServer.$lessinit$greater$default$3(), | ||
| KafkaServer.$lessinit$greater$default$4()); |
There was a problem hiding this comment.
Using Scala compiler-generated default argument methods (like $lessinit$greater$default$2()) directly in Java is fragile and highly discouraged. These synthetic methods are internal implementation details of the Scala compiler and can change across Scala compiler versions or if the constructor parameters are reordered/modified in future Kafka releases.
Instead, pass explicit, standard Scala/Java instances such as org.apache.kafka.common.utils.Time.SYSTEM, scala.Option.empty(), and scala.collection.immutable.List$.MODULE$.empty().
| KafkaServer server = | |
| new KafkaServer( | |
| new KafkaConfig(props), | |
| KafkaServer.$lessinit$greater$default$2(), | |
| KafkaServer.$lessinit$greater$default$3(), | |
| KafkaServer.$lessinit$greater$default$4()); | |
| KafkaServer server = | |
| new KafkaServer( | |
| new KafkaConfig(props), | |
| org.apache.kafka.common.utils.Time.SYSTEM, | |
| scala.Option.empty(), | |
| scala.collection.immutable.List$.MODULE$.empty()); |
There was a problem hiding this comment.
Using Scala compiler-generated default argument methods (like $lessinit$greater$default$2()) directly in Java is fragile and highly discouraged.
Needs citation?
Jokes aside, that last argument is supposed to be a Boolean so this is not exactly the right suggestion.
I don't feel strongly about this, Kafka itself instantiates KafkaServer as follows in main:
new KafkaServer(
config,
Time.SYSTEM,
threadNamePrefix = None,
enableForwarding = enableApiForwarding(config)
)Other than readability I don't see a good reason not to use the generated methods to access default arguments.
If the signature were to change due to argument reordering as mentioned, then the suggested change would break at compile time whereas the generated methods would return the expected type because their definition depends on the signature definition itself.
| server = | ||
| new KafkaServer( | ||
| KafkaConfig.fromProps(kafkaProperties), | ||
| KafkaServer.$lessinit$greater$default$2(), | ||
| KafkaServer.$lessinit$greater$default$3(), | ||
| KafkaServer.$lessinit$greater$default$4()); |
There was a problem hiding this comment.
Using Scala compiler-generated default argument methods (like $lessinit$greater$default$2()) directly in Java is fragile and highly discouraged. These synthetic methods are internal implementation details of the Scala compiler and can change across Scala compiler versions or if the constructor parameters are reordered/modified in future Kafka releases.
Instead, pass explicit, standard Scala/Java instances such as org.apache.kafka.common.utils.Time.SYSTEM, scala.Option.empty(), and scala.collection.immutable.List$.MODULE$.empty().
| server = | |
| new KafkaServer( | |
| KafkaConfig.fromProps(kafkaProperties), | |
| KafkaServer.$lessinit$greater$default$2(), | |
| KafkaServer.$lessinit$greater$default$3(), | |
| KafkaServer.$lessinit$greater$default$4()); | |
| server = | |
| new KafkaServer( | |
| KafkaConfig.fromProps(kafkaProperties), | |
| org.apache.kafka.common.utils.Time.SYSTEM, | |
| scala.Option.empty(), | |
| scala.collection.immutable.List$.MODULE$.empty()); |
There was a problem hiding this comment.
Using Scala compiler-generated default argument methods (like $lessinit$greater$default$2()) directly in Java is fragile and highly discouraged.
Needs citation?
Jokes aside, that last argument is supposed to be a Boolean so this is not exactly the right suggestion.
I don't feel strongly about this, Kafka itself instantiates KafkaServer as follows in main:
new KafkaServer(
config,
Time.SYSTEM,
threadNamePrefix = None,
enableForwarding = enableApiForwarding(config)
)Other than readability I don't see a good reason not to use the generated methods to access default arguments.
If the signature were to change due to argument reordering as mentioned, then the suggested change would break at compile time whereas the generated methods would return the expected type because their definition depends on the signature definition itself.
8b6b19a to
c036403
Compare
46e5772 to
8e1389c
Compare
8e1389c to
4da22b0
Compare
|
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment |
Remove build support for legacy Kafka clients. The Kafka protocol implementation in Kafka client version 3.9.2 still allows users to connect to legacy Kafka brokers. See KIP-896 for details on protocol compatibility.
This PR was split from #36834 and enables opportunities to improve KafkaIO performance by leveraging new client features.
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>instead.CHANGES.mdwith noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.