You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "sjvanrossum (via GitHub)" <gi...@apache.org> on 2026/07/10 17:13:07 UTC
[PR] [KafkaIO] Remove build support for Kafka clients before 3.9.2 [beam]
sjvanrossum opened a new pull request, #39284:
URL: https://github.com/apache/beam/pull/39284
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](https://cwiki.apache.org/confluence/spaces/KAFKA/pages/235838251/KIP-896+Remove+old+client+protocol+API+versions+in+Kafka+4.0) 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:
- [ ] Mention the appropriate issue in your description (for example: `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, comment `fixes #<ISSUE NUMBER>` instead.
- [ ] Update `CHANGES.md` with noteworthy changes.
- [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier).
To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
GitHub Actions Tests Status (on master branch)
------------------------------------------------------------------------------------------------
[](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule)
See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI or the [workflows README](https://github.com/apache/beam/blob/master/.github/workflows/README.md) to see a list of phrases to trigger workflows.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [KafkaIO] Remove build support for Kafka clients before 3.9.2 [beam]
Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on PR #39284:
URL: https://github.com/apache/beam/pull/39284#issuecomment-4937750730
## Summary of Changes
Hello, I'm Gemini Code Assist[^1]! 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
* **Kafka Client Upgrade**: Upgraded the Kafka client version to 3.9.2 across the project, removing support for older legacy versions.
* **Build Configuration Cleanup**: Removed legacy Kafka version build modules and updated build dependencies to use the new Kafka 3.9.2 artifacts.
* **Code Refactoring**: Updated internal Kafka test utilities to accommodate API changes in Kafka 3.9.2, specifically replacing KafkaServerStartable with KafkaServer.
<details>
<summary><b>New Features</b></summary>
🧠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](https://codeassist.google/code-review/login) to enable Memory in your admin console.**
</details>
<details>
<summary><b>Using Gemini Code Assist</b></summary>
<br>
The full guide for Gemini Code Assist can be found on our [documentation page](https://developers.google.com/gemini-code-assist/docs/review-github-code), here are some quick tips.
<b>Invoking Gemini</b>
You can request assistance from Gemini at any point by creating a comment using either `/gemini <command>` or `@gemini-code-assist <command>`. Below is a summary of the supported commands on the current page.
Feature | Command | Description
--- | --- | ---
Code Review | `/gemini review` | Performs a code review for the current pull request in its current state.
Pull Request Summary | `/gemini summary` | Provides a summary of the current pull request in its current state.
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help | `/gemini help` | Displays a list of available commands.
<b>Customization</b>
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 `.gemini/` folder in the base of the repository. Detailed instructions can be found [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github).
<b>Limitations & Feedback</b>
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with :thumbsup: and :thumbsdown: 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](https://google.qualtrics.com/jfe/form/SV_2cyuGuTWsEw84yG).
</details>
[^1]: Review the [Privacy Notices](https://policies.google.com/privacy), [Generative AI Prohibited Use Policy](https://policies.google.com/terms/generative-ai/use-policy), [Terms of Service](https://policies.google.com/terms), and learn how to configure Gemini Code Assist in GitHub [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). Gemini can make mistakes, so double check it and [use code with caution](https://support.google.com/legal/answer/13505487).
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [KafkaIO] Remove build support for Kafka clients before 3.9.2 [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #39284:
URL: https://github.com/apache/beam/pull/39284#issuecomment-4953000729
Assigning reviewers:
R: @Abacn for label java.
R: @liferoad for label build.
R: @johnjcasey for label kafka.
Note: If you would like to opt out of this review, comment `assign to next reviewer`.
Available commands:
- `stop reviewer notifications` - opt out of the automated review tooling
- `remind me after tests pass` - tag the comment author after tests pass
- `waiting on author` - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)
The PR bot will only process comments in the main thread (not review comments).
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [KafkaIO] Remove build support for Kafka clients before 3.9.2 [beam]
Posted by "sjvanrossum (via GitHub)" <gi...@apache.org>.
sjvanrossum commented on code in PR #39284:
URL: https://github.com/apache/beam/pull/39284#discussion_r3561494828
##########
sdks/java/testing/kafka-service/src/test/java/org/apache/beam/sdk/testing/kafka/LocalKafka.java:
##########
@@ -20,18 +20,23 @@
import java.nio.file.Files;
import java.util.Properties;
import kafka.server.KafkaConfig;
-import kafka.server.KafkaServerStartable;
+import kafka.server.KafkaServer;
public class LocalKafka {
- private final KafkaServerStartable server;
+ private final KafkaServer server;
LocalKafka(int kafkaPort, int zookeeperPort) throws Exception {
Properties kafkaProperties = new Properties();
kafkaProperties.setProperty("port", String.valueOf(kafkaPort));
kafkaProperties.setProperty("zookeeper.connect", String.format("localhost:%s", zookeeperPort));
kafkaProperties.setProperty("offsets.topic.replication.factor", "1");
kafkaProperties.setProperty("log.dir", Files.createTempDirectory("kafka-log-").toString());
- server = new KafkaServerStartable(KafkaConfig.fromProps(kafkaProperties));
+ server =
+ new KafkaServer(
+ KafkaConfig.fromProps(kafkaProperties),
+ KafkaServer.$lessinit$greater$default$2(),
+ KafkaServer.$lessinit$greater$default$3(),
+ KafkaServer.$lessinit$greater$default$4());
Review 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:
```scala
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.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [KafkaIO] Remove build support for Kafka clients before 3.9.2 [beam]
Posted by "sjvanrossum (via GitHub)" <gi...@apache.org>.
sjvanrossum commented on PR #39284:
URL: https://github.com/apache/beam/pull/39284#issuecomment-4967279753
Run Flink Container PreCommit
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [KafkaIO] Remove build support for Kafka clients before 3.9.2 [beam]
Posted by "Abacn (via GitHub)" <gi...@apache.org>.
Abacn commented on PR #39284:
URL: https://github.com/apache/beam/pull/39284#issuecomment-5025791247
Thanks
When all tests are confirmed working, consider adding an announcement in CHANGES.md noting that Beam now requires kafka 3.9.2+
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [KafkaIO] Remove build support for Kafka clients before 3.9.2 [beam]
Posted by "Abacn (via GitHub)" <gi...@apache.org>.
Abacn merged PR #39284:
URL: https://github.com/apache/beam/pull/39284
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [KafkaIO] Remove build support for Kafka clients before 3.9.2 [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #39284:
URL: https://github.com/apache/beam/pull/39284#issuecomment-4941208029
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment `assign set of reviewers`
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [KafkaIO] Remove build support for Kafka clients before 3.9.2 [beam]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #39284:
URL: https://github.com/apache/beam/pull/39284#issuecomment-4953034663
## [Codecov](https://app.codecov.io/gh/apache/beam/pull/39284?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 58.04%. Comparing base ([`7d682e2`](https://app.codecov.io/gh/apache/beam/commit/7d682e210f99133633c72ad12cd75f18b80ba7c1?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`a15436d`](https://app.codecov.io/gh/apache/beam/commit/a15436d31336a200a1b148d7c411769d6cb3e21b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 6 commits behind head on master.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #39284 +/- ##
============================================
+ Coverage 54.76% 58.04% +3.28%
- Complexity 1716 13053 +11337
============================================
Files 1066 2515 +1449
Lines 169067 263741 +94674
Branches 1255 10761 +9506
============================================
+ Hits 92587 153091 +60504
- Misses 74263 104901 +30638
- Partials 2217 5749 +3532
```
| [Flag](https://app.codecov.io/gh/apache/beam/pull/39284/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [java](https://app.codecov.io/gh/apache/beam/pull/39284/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `64.23% <ø> (-3.38%)` | :arrow_down: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/beam/pull/39284?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [KafkaIO] Remove build support for Kafka clients before 3.9.2 [beam]
Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on code in PR #39284:
URL: https://github.com/apache/beam/pull/39284#discussion_r3560715217
##########
runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/utils/EmbeddedKafkaCluster.java:
##########
@@ -114,15 +114,20 @@ public void startup() {
properties.setProperty("offsets.topic.replication.factor", "1");
properties.setProperty("log.flush.interval.messages", String.valueOf(1));
- KafkaServerStartable broker = startBroker(properties);
+ KafkaServer broker = startBroker(properties);
brokers.add(broker);
logDirs.add(logDir);
}
}
- private static KafkaServerStartable startBroker(Properties props) {
- KafkaServerStartable server = new KafkaServerStartable(new KafkaConfig(props));
+ private static KafkaServer startBroker(Properties props) {
+ KafkaServer server =
+ new KafkaServer(
+ new KafkaConfig(props),
+ KafkaServer.$lessinit$greater$default$2(),
+ KafkaServer.$lessinit$greater$default$3(),
+ KafkaServer.$lessinit$greater$default$4());
Review 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()`.
```suggestion
KafkaServer server =
new KafkaServer(
new KafkaConfig(props),
org.apache.kafka.common.utils.Time.SYSTEM,
scala.Option.empty(),
scala.collection.immutable.List$.MODULE$.empty());
```
##########
sdks/java/testing/kafka-service/src/test/java/org/apache/beam/sdk/testing/kafka/LocalKafka.java:
##########
@@ -20,18 +20,23 @@
import java.nio.file.Files;
import java.util.Properties;
import kafka.server.KafkaConfig;
-import kafka.server.KafkaServerStartable;
+import kafka.server.KafkaServer;
public class LocalKafka {
- private final KafkaServerStartable server;
+ private final KafkaServer server;
LocalKafka(int kafkaPort, int zookeeperPort) throws Exception {
Properties kafkaProperties = new Properties();
kafkaProperties.setProperty("port", String.valueOf(kafkaPort));
kafkaProperties.setProperty("zookeeper.connect", String.format("localhost:%s", zookeeperPort));
kafkaProperties.setProperty("offsets.topic.replication.factor", "1");
kafkaProperties.setProperty("log.dir", Files.createTempDirectory("kafka-log-").toString());
- server = new KafkaServerStartable(KafkaConfig.fromProps(kafkaProperties));
+ server =
+ new KafkaServer(
+ KafkaConfig.fromProps(kafkaProperties),
+ KafkaServer.$lessinit$greater$default$2(),
+ KafkaServer.$lessinit$greater$default$3(),
+ KafkaServer.$lessinit$greater$default$4());
Review 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()`.
```suggestion
server =
new KafkaServer(
KafkaConfig.fromProps(kafkaProperties),
org.apache.kafka.common.utils.Time.SYSTEM,
scala.Option.empty(),
scala.collection.immutable.List$.MODULE$.empty());
```
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [KafkaIO] Remove build support for Kafka clients before 3.9.2 [beam]
Posted by "sjvanrossum (via GitHub)" <gi...@apache.org>.
sjvanrossum commented on code in PR #39284:
URL: https://github.com/apache/beam/pull/39284#discussion_r3561496973
##########
runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/utils/EmbeddedKafkaCluster.java:
##########
@@ -114,15 +114,20 @@ public void startup() {
properties.setProperty("offsets.topic.replication.factor", "1");
properties.setProperty("log.flush.interval.messages", String.valueOf(1));
- KafkaServerStartable broker = startBroker(properties);
+ KafkaServer broker = startBroker(properties);
brokers.add(broker);
logDirs.add(logDir);
}
}
- private static KafkaServerStartable startBroker(Properties props) {
- KafkaServerStartable server = new KafkaServerStartable(new KafkaConfig(props));
+ private static KafkaServer startBroker(Properties props) {
+ KafkaServer server =
+ new KafkaServer(
+ new KafkaConfig(props),
+ KafkaServer.$lessinit$greater$default$2(),
+ KafkaServer.$lessinit$greater$default$3(),
+ KafkaServer.$lessinit$greater$default$4());
Review 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:
```scala
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.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org