FrankYang0529 commented on code in PR #17731:
URL: https://github.com/apache/kafka/pull/17731#discussion_r2527897759


##########
core/src/main/scala/kafka/network/SocketServer.scala:
##########
@@ -1133,23 +1133,27 @@ private[kafka] class Processor(
                 expiredConnectionsKilledCount.record(null, 1, 0)
               } else {
                 val connectionId = receive.source
-                val context = new RequestContext(header, connectionId, 
channel.socketAddress, Optional.of(channel.socketPort()),
-                  channel.principal, listenerName, securityProtocol, 
channel.channelMetadataRegistry.clientInformation,
-                  isPrivilegedListener, channel.principalSerde)
-
-                val req = new RequestChannel.Request(processor = id, context = 
context,
-                  startTimeNanos = nowNanos, memoryPool, receive.payload, 
requestChannel.metrics, None)
-
+                var requestAndSize: Option[RequestAndSize] = None
                 // KIP-511: ApiVersionsRequest is intercepted here to catch 
the client software name
                 // and version. It is done here to avoid wiring things up to 
the api layer.
                 if (header.apiKey == ApiKeys.API_VERSIONS) {
-                  val apiVersionsRequest = req.body[ApiVersionsRequest]
+                  val result = RequestContext.staticParseRequest(header, 
receive.payload, connectionId, listenerName, channel.principal)
+                  val apiVersionsRequest = 
result.request.asInstanceOf[ApiVersionsRequest]
                   if (apiVersionsRequest.isValid) {
                     
channel.channelMetadataRegistry.registerClientInformation(new ClientInformation(
                       apiVersionsRequest.data.clientSoftwareName,
                       apiVersionsRequest.data.clientSoftwareVersion))

Review Comment:
   @kirktrue Thanks for the review. Here has some circular dependencies. We 
want to set client information to context, but we also need context to parse 
the `receive.payload` buffer to get `req.body`. If we want to get `req` before 
`context`, we need lot of changes here. I prefer to set client information as 
current solution.



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