vamossagar12 commented on code in PR #13131:
URL: https://github.com/apache/kafka/pull/13131#discussion_r1083413458


##########
core/src/main/scala/kafka/utils/ToolsUtils.scala:
##########
@@ -64,4 +65,18 @@ object ToolsUtils {
         println(s"%-${maxLengthOfDisplayName}s : 
$specifier".format(metricName, value))
     }
   }
+
+  /**
+   * This is a simple wrapper around `CommandLineUtils.printUsageAndDie`.
+   * It is needed for tools migration (KAFKA-14525), as there is no Java 
equivalent for return type `Nothing`.
+   * Can be removed once [[kafka.admin.ConsumerGroupCommand]], 
[[kafka.tools.ConsoleConsumer]]
+   * and [[kafka.tools.ConsoleProducer]] are migrated.
+   *
+   * @param parser Command line options parser.
+   * @param message Error message.
+   */
+  def printUsageAndDie(parser: OptionParser, message: String): Nothing = {

Review Comment:
   I am thinking if we can add another parameter to this to say if we want to 
do an Exit(1) from this method or not. I see some places where Exit(1) is not 
being invoked from the scala layer. 



##########
core/src/main/scala/kafka/admin/ConsumerGroupCommand.scala:
##########
@@ -801,15 +801,21 @@ object ConsumerGroupCommand extends Logging {
         partitionsToReset.map { topicPartition =>
           logStartOffsets.get(topicPartition) match {
             case Some(LogOffsetResult.LogOffset(offset)) => (topicPartition, 
new OffsetAndMetadata(offset))
-            case _ => CommandLineUtils.printUsageAndDie(opts.parser, s"Error 
getting starting offset of topic partition: $topicPartition")
+            case _ => {
+              CommandLineUtils.printUsageAndDie(opts.parser, s"Error getting 
starting offset of topic partition: $topicPartition")
+              Exit.exit(1)

Review Comment:
   Thanks @fvaleri . Wondering if these and other similar lines can be changed 
to use ToolsUtils. printUsageAndDie()? 



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to