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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]