You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ma...@apache.org on 2020/04/01 03:16:28 UTC
[kafka] branch trunk updated: MINOR: reduce garbage in operation
and resource java conversions (#8391)
This is an automated email from the ASF dual-hosted git repository.
manikumar 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 cb91251 MINOR: reduce garbage in operation and resource java conversions (#8391)
cb91251 is described below
commit cb9125106d69f4662df070cb2196341066698a5e
Author: Lucas Bradstreet <lu...@confluent.io>
AuthorDate: Tue Mar 31 20:16:06 2020 -0700
MINOR: reduce garbage in operation and resource java conversions (#8391)
Reviewers: Manikumar Reddy <ma...@gmail.com>
---
core/src/main/scala/kafka/security/auth/Operation.scala | 17 ++++++++++++++++-
.../main/scala/kafka/security/auth/ResourceType.scala | 13 +++++++++++--
2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/core/src/main/scala/kafka/security/auth/Operation.scala b/core/src/main/scala/kafka/security/auth/Operation.scala
index 1c71077..3ae2384 100644
--- a/core/src/main/scala/kafka/security/auth/Operation.scala
+++ b/core/src/main/scala/kafka/security/auth/Operation.scala
@@ -91,7 +91,22 @@ object Operation {
op.getOrElse(throw new KafkaException(operation + " not a valid operation name. The valid names are " + values.mkString(",")))
}
- def fromJava(operation: AclOperation): Operation = fromString(operation.toString.replaceAll("_", ""))
+ def fromJava(operation: AclOperation): Operation = {
+ operation match {
+ case AclOperation.READ => Read
+ case AclOperation.WRITE => Write
+ case AclOperation.CREATE => Create
+ case AclOperation.DELETE => Delete
+ case AclOperation.ALTER => Alter
+ case AclOperation.DESCRIBE => Describe
+ case AclOperation.CLUSTER_ACTION => ClusterAction
+ case AclOperation.ALTER_CONFIGS => AlterConfigs
+ case AclOperation.DESCRIBE_CONFIGS => DescribeConfigs
+ case AclOperation.IDEMPOTENT_WRITE => IdempotentWrite
+ case AclOperation.ALL => All
+ case _ => throw new KafkaException(operation + " is not a convertible operation name. The valid names are " + values.mkString(","))
+ }
+ }
def values: Seq[Operation] = List(Read, Write, Create, Delete, Alter, Describe, ClusterAction, AlterConfigs,
DescribeConfigs, IdempotentWrite, All)
diff --git a/core/src/main/scala/kafka/security/auth/ResourceType.scala b/core/src/main/scala/kafka/security/auth/ResourceType.scala
index 42214c7..72b71c0 100644
--- a/core/src/main/scala/kafka/security/auth/ResourceType.scala
+++ b/core/src/main/scala/kafka/security/auth/ResourceType.scala
@@ -78,7 +78,16 @@ object ResourceType {
rType.getOrElse(throw new KafkaException(resourceType + " not a valid resourceType name. The valid names are " + values.mkString(",")))
}
- def values: Seq[ResourceType] = List(Topic, Group, Cluster, TransactionalId, DelegationToken)
+ def fromJava(resourceType: JResourceType): ResourceType = {
+ resourceType match {
+ case JResourceType.TOPIC => Topic
+ case JResourceType.GROUP => Group
+ case JResourceType.CLUSTER => Cluster
+ case JResourceType.TRANSACTIONAL_ID => TransactionalId
+ case JResourceType.DELEGATION_TOKEN => DelegationToken
+ case _ => throw new KafkaException(resourceType + " is not a convertible resource type. The valid types are " + values.mkString(","))
+ }
+ }
- def fromJava(operation: JResourceType): ResourceType = fromString(operation.toString.replaceAll("_", ""))
+ def values: Seq[ResourceType] = List(Topic, Group, Cluster, TransactionalId, DelegationToken)
}