Repository: kafka
Updated Branches:
  refs/heads/trunk b8cfa167e -> 2965f50e0


MINOR: Replaced unnecessary map and getOrElse with exists

Author: himani1 <1himani.ar...@gmail.com>

Reviewers: Jason Gustafson <ja...@confluent.io>

Closes #2035 from himani1/code_refactored


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/2965f50e
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/2965f50e
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/2965f50e

Branch: refs/heads/trunk
Commit: 2965f50e0de755cd36cf5e13bd9968493a0f8279
Parents: b8cfa16
Author: himani1 <1himani.ar...@gmail.com>
Authored: Tue Oct 18 22:12:08 2016 -0700
Committer: Jason Gustafson <ja...@confluent.io>
Committed: Tue Oct 18 22:12:08 2016 -0700

----------------------------------------------------------------------
 .../kafka/security/auth/SimpleAclAuthorizer.scala     | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/2965f50e/core/src/main/scala/kafka/security/auth/SimpleAclAuthorizer.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/kafka/security/auth/SimpleAclAuthorizer.scala 
b/core/src/main/scala/kafka/security/auth/SimpleAclAuthorizer.scala
index 42bfebf..72f79d5 100644
--- a/core/src/main/scala/kafka/security/auth/SimpleAclAuthorizer.scala
+++ b/core/src/main/scala/kafka/security/auth/SimpleAclAuthorizer.scala
@@ -161,15 +161,15 @@ class SimpleAclAuthorizer extends Authorizer with Logging 
{
   }
 
   private def aclMatch(session: Session, operations: Operation, resource: 
Resource, principal: KafkaPrincipal, host: String, permissionType: 
PermissionType, acls: Set[Acl]): Boolean = {
-    acls.find ( acl =>
-      acl.permissionType == permissionType
-        && (acl.principal == principal || acl.principal == 
Acl.WildCardPrincipal)
-        && (operations == acl.operation || acl.operation == All)
-        && (acl.host == host || acl.host == Acl.WildCardHost)
-    ).map { acl: Acl =>
+    acls.find { acl =>
+      acl.permissionType == permissionType &&
+        (acl.principal == principal || acl.principal == Acl.WildCardPrincipal) 
&&
+        (operations == acl.operation || acl.operation == All) &&
+        (acl.host == host || acl.host == Acl.WildCardHost)
+    }.exists { acl =>
       authorizerLogger.debug(s"operation = $operations on resource = $resource 
from host = $host is $permissionType based on acl = $acl")
       true
-    }.getOrElse(false)
+    }
   }
 
   override def addAcls(acls: Set[Acl], resource: Resource) {

Reply via email to