cmccabe commented on a change in pull request #10184:
URL: https://github.com/apache/kafka/pull/10184#discussion_r582259112



##########
File path: core/src/main/scala/kafka/server/ControllerApis.scala
##########
@@ -195,6 +198,61 @@ class ControllerApis(val requestChannel: RequestChannel,
       requestThrottleMs => createResponseCallback(requestThrottleMs))
   }
 
+  def handleDeleteTopics(request: RequestChannel.Request): Unit = {
+    if (!config.deleteTopicEnable) {
+      if (request.context.apiVersion() < 3) {
+        throw new InvalidRequestException("Topic deletion is disabled.")
+      } else {
+        throw new TopicDeletionDisabledException()
+      }
+    }
+    val deleteTopicsRequest = request.body[DeleteTopicsRequest]
+    val nameToId = new mutable.HashMap[String, Uuid]
+    deleteTopicsRequest.data().topicNames().iterator().asScala.foreach {
+      name => nameToId.put(name, Uuid.ZERO_UUID)
+    }
+    deleteTopicsRequest.data().topics().iterator().asScala.foreach {
+      nameAndId => nameToId.put(nameAndId.name(), nameAndId.topicId())
+    }
+    val (describable, deletable)  = {
+      if (authHelper.authorize(request.context, DELETE, CLUSTER, 
CLUSTER_NAME)) {
+        (nameToId.keySet, nameToId.keySet)
+      } else {
+        val authorizedDescribeTopics: Set[String] = 
authHelper.filterByAuthorized(
+          request.context, DESCRIBE, TOPIC, nameToId.keys)(n => n)
+        val authorizedDeleteTopics: Set[String] = 
authHelper.filterByAuthorized(
+          request.context, DELETE, TOPIC, nameToId.keys)(n => n)
+        (authorizedDescribeTopics, authorizedDeleteTopics)
+      }
+    }
+    def sendResponse(response: DeleteTopicsResponseData): Unit = {
+      nameToId.keysIterator.foreach {

Review comment:
       the main rationale for this is that I don't want scala to perform any 
copying, and I know for sure that if I give an iterator that it won't.
   
   I wouldn't mind using Java's forEach directly but I couldn't find a good way 
to convert a scala closure to a java closure (maybe this is obvious and I 
missed it?)




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

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


Reply via email to