This is an automated email from the ASF dual-hosted git repository.

dengziming pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 42cfd57a249 MINOR: Fix some compiler warnings (#12912)
42cfd57a249 is described below

commit 42cfd57a2498b1a997e77cc24ec38b3722cc1f6a
Author: Gantigmaa Selenge <[email protected]>
AuthorDate: Wed Dec 7 13:23:01 2022 +0000

    MINOR: Fix some compiler warnings (#12912)
    
    Reviewers: Ismael Juma <[email protected]>, Luke Chen <[email protected]>
---
 core/src/main/scala/kafka/admin/ConfigCommand.scala      | 16 ++++++++--------
 .../scala/kafka/admin/ReassignPartitionsCommand.scala    |  2 +-
 core/src/main/scala/kafka/admin/TopicCommand.scala       |  2 +-
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/core/src/main/scala/kafka/admin/ConfigCommand.scala 
b/core/src/main/scala/kafka/admin/ConfigCommand.scala
index c5a62e7eb95..edd37932f76 100644
--- a/core/src/main/scala/kafka/admin/ConfigCommand.scala
+++ b/core/src/main/scala/kafka/admin/ConfigCommand.scala
@@ -135,7 +135,7 @@ object ConfigCommand extends Logging {
     val errorMessage = s"--bootstrap-server option must be specified to update 
$entityType configs: {add: $configsToBeAdded, delete: $configsToBeDeleted}"
 
     if (entityType == ConfigType.User) {
-      if (!configsToBeAdded.isEmpty || !configsToBeDeleted.isEmpty) {
+      if (!configsToBeAdded.isEmpty || configsToBeDeleted.nonEmpty) {
         val info = "User configuration updates using ZooKeeper are only 
supported for SCRAM credential updates."
         val scramMechanismNames = ScramMechanism.values.map(_.mechanismName)
         // make sure every added/deleted configs are SCRAM related, other 
configs are not supported using zookeeper
@@ -146,7 +146,7 @@ object ConfigCommand extends Logging {
       preProcessScramCredentials(configsToBeAdded)
     } else if (entityType == ConfigType.Broker) {
       // Dynamic broker configs can be updated using ZooKeeper only if the 
corresponding broker is not running.
-      if (!configsToBeAdded.isEmpty || !configsToBeDeleted.isEmpty) {
+      if (!configsToBeAdded.isEmpty || configsToBeDeleted.nonEmpty) {
         validateBrokersNotRunning(entityName, adminZkClient, zkClient, 
errorMessage)
 
         val perBrokerConfig = entityName != ConfigEntityName.Default
@@ -253,7 +253,7 @@ object ConfigCommand extends Logging {
   private[admin] def describeConfigWithZk(zkClient: KafkaZkClient, opts: 
ConfigCommandOptions, adminZkClient: AdminZkClient): Unit = {
     val configEntity = parseEntity(opts)
     val entityType = configEntity.root.entityType
-    val describeAllUsers = entityType == ConfigType.User && 
!configEntity.root.sanitizedName.isDefined && !configEntity.child.isDefined
+    val describeAllUsers = entityType == ConfigType.User && 
configEntity.root.sanitizedName.isEmpty && configEntity.child.isEmpty
     val entityName = configEntity.fullSanitizedName
     val errorMessage = s"--bootstrap-server option must be specified to 
describe $entityType"
     if (entityType == ConfigType.Broker) {
@@ -548,7 +548,7 @@ object ConfigCommand extends Logging {
 
     val (configResourceType, dynamicConfigSource) = entityType match {
       case ConfigType.Topic =>
-        if (!entityName.isEmpty)
+        if (entityName.nonEmpty)
           Topic.validate(entityName)
         (ConfigResource.Type.TOPIC, 
Some(ConfigEntry.ConfigSource.DYNAMIC_TOPIC_CONFIG))
       case ConfigType.Broker => entityName match {
@@ -559,7 +559,7 @@ object ConfigCommand extends Logging {
           (ConfigResource.Type.BROKER, 
Some(ConfigEntry.ConfigSource.DYNAMIC_BROKER_CONFIG))
       }
       case BrokerLoggerConfigType =>
-        if (!entityName.isEmpty)
+        if (entityName.nonEmpty)
           validateBrokerId()
         (ConfigResource.Type.BROKER_LOGGER, None)
       case entityType => throw new IllegalArgumentException(s"Invalid entity 
type: $entityType")
@@ -581,7 +581,7 @@ object ConfigCommand extends Logging {
       }).toSeq
   }
 
-  private def describeQuotaConfigs(adminClient: Admin, entityTypes: 
List[String], entityNames: List[String]) = {
+  private def describeQuotaConfigs(adminClient: Admin, entityTypes: 
List[String], entityNames: List[String]): Unit = {
     val quotaConfigs = getAllClientQuotasConfigs(adminClient, entityTypes, 
entityNames)
     quotaConfigs.forKeyValue { (entity, entries) =>
       val entityEntries = entity.entries.asScala
@@ -605,7 +605,7 @@ object ConfigCommand extends Logging {
     }
   }
 
-  private def describeClientQuotaAndUserScramCredentialConfigs(adminClient: 
Admin, entityTypes: List[String], entityNames: List[String]) = {
+  private def describeClientQuotaAndUserScramCredentialConfigs(adminClient: 
Admin, entityTypes: List[String], entityNames: List[String]): Unit = {
     describeQuotaConfigs(adminClient, entityTypes, entityNames)
     // we describe user SCRAM credentials only when we are not describing 
client information
     // and we are not given either --entity-default or --user-defaults
@@ -889,7 +889,7 @@ object ConfigCommand extends Logging {
         (entityFlags ++ entityDefaultsFlags).exists(entity => 
options.has(entity._1)))
         throw new IllegalArgumentException("--entity-{type,name,default} 
should not be used in conjunction with specific entity flags")
 
-      val hasEntityName = entityNames.exists(!_.isEmpty)
+      val hasEntityName = entityNames.exists(_.nonEmpty)
       val hasEntityDefault = entityNames.exists(_.isEmpty)
 
       if (!options.has(bootstrapServerOpt) && !options.has(zkConnectOpt))
diff --git a/core/src/main/scala/kafka/admin/ReassignPartitionsCommand.scala 
b/core/src/main/scala/kafka/admin/ReassignPartitionsCommand.scala
index ac454584e91..8bb92da8921 100755
--- a/core/src/main/scala/kafka/admin/ReassignPartitionsCommand.scala
+++ b/core/src/main/scala/kafka/admin/ReassignPartitionsCommand.scala
@@ -1341,7 +1341,7 @@ object ReassignPartitionsCommand extends Logging {
       CommandLineUtils.printUsageAndDie(opts.parser, "Command must include 
exactly one action: %s".format(
         validActions.map("--" + _.options().get(0)).mkString(", ")))
     }
-    val action = allActions(0)
+    val action = allActions.head
 
     if (!opts.options.has(opts.bootstrapServerOpt))
       CommandLineUtils.printUsageAndDie(opts.parser, "Please specify 
--bootstrap-server")
diff --git a/core/src/main/scala/kafka/admin/TopicCommand.scala 
b/core/src/main/scala/kafka/admin/TopicCommand.scala
index e5d60670892..abecc383fbd 100755
--- a/core/src/main/scala/kafka/admin/TopicCommand.scala
+++ b/core/src/main/scala/kafka/admin/TopicCommand.scala
@@ -587,7 +587,7 @@ object TopicCommand extends Logging {
     def partitions: Option[Integer] = valueAsOption(partitionsOpt)
     def replicationFactor: Option[Integer] = 
valueAsOption(replicationFactorOpt)
     def replicaAssignment: Option[Map[Int, List[Int]]] =
-      if (has(replicaAssignmentOpt) && 
!Option(options.valueOf(replicaAssignmentOpt)).getOrElse("").isEmpty)
+      if (has(replicaAssignmentOpt) && 
Option(options.valueOf(replicaAssignmentOpt)).getOrElse("").nonEmpty)
         Some(parseReplicaAssignment(options.valueOf(replicaAssignmentOpt)))
       else
         None

Reply via email to