showuon commented on code in PR #12480:
URL: https://github.com/apache/kafka/pull/12480#discussion_r954465533


##########
core/src/test/scala/integration/kafka/api/MetricsTest.scala:
##########
@@ -226,7 +226,7 @@ class MetricsTest extends IntegrationTestHarness with 
SaslSetup {
 
   private def verifyBrokerErrorMetrics(server: KafkaServer): Unit = {
 
-    def errorMetricCount = 
KafkaYammerMetrics.defaultRegistry.allMetrics.keySet.asScala.filter(_.getName 
== "ErrorsPerSec").size
+    def errorMetricCount = 
KafkaYammerMetrics.defaultRegistry.allMetrics.keySet.asScala.count(_.getName == 
"ErrorsPerSec")

Review Comment:
   nice



##########
core/src/test/scala/integration/kafka/api/SaslPlainSslEndToEndAuthorizationTest.scala:
##########
@@ -70,13 +70,12 @@ object SaslPlainSslEndToEndAuthorizationTest {
     def handle(callbacks: Array[Callback]): Unit = {
       var username: String = null
       for (callback <- callbacks) {
-        if (callback.isInstanceOf[NameCallback])
-          username = callback.asInstanceOf[NameCallback].getDefaultName
-        else if (callback.isInstanceOf[PlainAuthenticateCallback]) {
-          val plainCallback = callback.asInstanceOf[PlainAuthenticateCallback]
-          plainCallback.authenticated(Credentials.allUsers(username) == new 
String(plainCallback.password))
-        } else
-          throw new UnsupportedCallbackException(callback)
+        callback match {
+          case nameCallback: NameCallback => username = 
nameCallback.getDefaultName
+          case plainCallback: PlainAuthenticateCallback =>
+            plainCallback.authenticated(Credentials.allUsers(username) == new 
String(plainCallback.password))
+          case _ => throw new UnsupportedCallbackException(callback)
+        }

Review Comment:
   nice refactor!



-- 
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