junrao commented on code in PR #21005:
URL: https://github.com/apache/kafka/pull/21005#discussion_r2578351174


##########
core/src/main/scala/kafka/server/ControllerApis.scala:
##########
@@ -720,47 +721,76 @@ class ControllerApis(
     val configChanges = new util.HashMap[ConfigResource,
       util.Map[String, Entry[AlterConfigOp.OpType, String]]]()
     val brokerLoggerResponses = new 
util.ArrayList[AlterConfigsResourceResponse](1)
+    val nullConfigsErrorResults = new 
util.IdentityHashMap[AlterConfigsResource, ApiError]()
     alterConfigsRequest.data.resources.forEach { resource =>
-      val configResource = new ConfigResource(
-        ConfigResource.Type.forId(resource.resourceType), 
resource.resourceName())
-      if (configResource.`type`().equals(ConfigResource.Type.BROKER_LOGGER)) {
-        val apiError = try {
-          runtimeLoggerManager.applyChangesForResource(
-            authHelper.authorize(request.context, CLUSTER_ACTION, CLUSTER, 
CLUSTER_NAME),
-            alterConfigsRequest.data().validateOnly(),
-            resource)
-          ApiError.NONE
-        } catch {
-          case t: Throwable => ApiError.fromThrowable(t)
+      try {
+        val nullUpdates = new util.ArrayList[String]()
+        resource.configs().forEach { config =>
+          if (config.configOperation() != AlterConfigOp.OpType.DELETE.id() &&
+            config.value() == null) {
+            nullUpdates.add(config.name())
+          }
         }
-        brokerLoggerResponses.add(new AlterConfigsResourceResponse().
-          setResourceName(resource.resourceName()).
-          setResourceType(resource.resourceType()).
-          setErrorCode(apiError.error().code()).
-          setErrorMessage(if (apiError.isFailure) 
apiError.messageWithFallback() else null))
-      } else if (configResource.`type`().equals(ConfigResource.Type.UNKNOWN)) {
-        response.responses().add(new AlterConfigsResourceResponse().
-          setErrorCode(UNSUPPORTED_VERSION.code()).
-          setErrorMessage("Unknown resource type " + resource.resourceType() + 
".").
-          setResourceName(resource.resourceName()).
-          setResourceType(resource.resourceType()))
-      } else if (!duplicateResources.contains(configResource)) {
-        val altersByName = new util.HashMap[String, 
Entry[AlterConfigOp.OpType, String]]()
-        resource.configs.forEach { config =>
-          altersByName.put(config.name, new 
util.AbstractMap.SimpleEntry[AlterConfigOp.OpType, String](
-            AlterConfigOp.OpType.forId(config.configOperation), config.value))
+        if (!nullUpdates.isEmpty) {
+          throw new InvalidRequestException("Null value not supported for : " +

Review Comment:
   Would it be better to just set the error response here instead of throwing?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to