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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to